rust-msi
rust-msi copied to clipboard
MSCFthread 'main' panicked at extract
Using this file:
https://static.rust-lang.org/dist/rust-1.48.0-x86_64-pc-windows-gnu.msi
I can read:
PS C:\rust-msi-master\target\debug\examples> .\msiinfo streams
rust-1.48.0-x86_64-pc-windows-gnu.msi
cab1.cab
cab2.cab
cab3.cab
cab4.cab
cab5.cab
but extract fails:
PS C:\rust-msi-master\target\debug\examples> .\msiinfo extract
rust-1.48.0-x86_64-pc-windows-gnu.msi cab1.cab
MSCFthread 'main' panicked at 'extract: Custom { kind: InvalidData, error:
"Windows stdio in console mode does not support writing non-UTF-8 byte
sequences" }', examples\msiinfo.rs:196:50
https://github.com/mdsteele/rust-msi/blob/3f4ebba42732263b5db194903e7e58d4eeb3cc87/examples/msiinfo.rs#L196
This seems to fix it:
diff --git a/examples/msiinfo.rs b/examples/msiinfo.rs
index ffc2e1e..4a0f18c 100644
--- a/examples/msiinfo.rs
+++ b/examples/msiinfo.rs
@@ -193,7 +193,8 @@ fn main() {
let stream_name = submatches.value_of("stream").unwrap();
let mut package = msi::open(path).expect("open package");
let mut stream = package.read_stream(&stream_name).expect("read");
- io::copy(&mut stream, &mut io::stdout()).expect("extract");
+ let mut out_o = std::fs::File::create(stream_name).unwrap();
+ io::copy(&mut stream, &mut out_o).expect("extract");
} else if let Some(submatches) = matches.subcommand_matches("streams") {
let path = submatches.value_of("path").unwrap();
let package = msi::open(path).expect("open package");