Skip to content

Commit 9ef2d5f

Browse files
Simplify path conversion in the example
1 parent 3281ff0 commit 9ef2d5f

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

examples/cat.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1313
use anyhow::{Context, Result};
1414
use ext4_view::Ext4;
15-
use std::ffi::OsString;
1615
use std::io::{self, ErrorKind, Read, Write};
1716
use std::{env, process};
1817

@@ -36,7 +35,8 @@ fn parse_args() -> Result<(std::path::PathBuf, ext4_view::PathBuf)> {
3635
}
3736

3837
let filesystem = std::path::PathBuf::from(&args[1]);
39-
let path = get_ext4_path(args[2].clone())?;
38+
let path = ext4_view::PathBuf::try_from(args[2].clone())
39+
.context("Invalid ext4 path")?;
4040

4141
Ok((filesystem, path))
4242
}
@@ -82,12 +82,3 @@ fn main() -> Result<()> {
8282
}
8383
}
8484
}
85-
86-
fn get_ext4_path(s: OsString) -> Result<ext4_view::PathBuf> {
87-
// TODO: implement a better conversion on Windows.
88-
// https://github.com/nicholasbishop/ext4-view-rs/issues/361
89-
#[cfg(windows)]
90-
let s = s.to_str().context("Path is not UTF-8")?;
91-
92-
ext4_view::PathBuf::try_from(s).context("Invalid ext4 path")
93-
}

0 commit comments

Comments
 (0)