summaryrefslogtreecommitdiff
path: root/src/path_list_editor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/path_list_editor.rs')
-rw-r--r--src/path_list_editor.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/path_list_editor.rs b/src/path_list_editor.rs
index a740bf2..bdd6982 100644
--- a/src/path_list_editor.rs
+++ b/src/path_list_editor.rs
@@ -9,13 +9,13 @@
use std::{
collections::HashSet,
- ffi::{OsStr, OsString},
+ ffi::OsString,
io::{Read, Write},
os::unix::ffi::OsStrExt,
- path::{Path, PathBuf},
+ path::PathBuf,
};
-use crate::normalizer::Normalizer;
+use crate::{normalizer::Normalizer, util::path_list::paths_from_null_separated_bytes};
const NUL: &[u8] = b"\0";
@@ -117,14 +117,10 @@ pub fn remove_paths<R: Read, W: Write>(
.iter()
.map(|path| normalizer.normalize(path))
.collect::<Result<HashSet<_>, _>>()?;
- for segment in input_buf.split(|b| *b == 0) {
- if segment.is_empty() {
- continue;
- }
- let os_string_segment = OsStr::from_bytes(segment);
- let normalized_path = normalizer.normalize(Path::new(os_string_segment))?;
+ for path in paths_from_null_separated_bytes(&input_buf) {
+ let normalized_path = normalizer.normalize(path)?;
if !unwanted_paths.contains(&normalized_path) {
- output.write_all(segment)?;
+ output.write_all(path.as_os_str().as_bytes())?;
output.write_all(NUL)?;
}
}