summaryrefslogtreecommitdiff
path: root/src/path_list_editor.rs
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2026-06-20 16:58:01 +0300
committerA Farzat <a@farzat.xyz>2026-06-20 19:45:59 +0300
commitf54df9fd6d50030beee064bfd1415bad066107d2 (patch)
tree0d2a2eb67045dc76bdb281945d41d919cc22802b /src/path_list_editor.rs
parent4ec209d3863e913cffbe8c6e0a14a292820a2715 (diff)
downloadrepo2markdown-f54df9fd6d50030beee064bfd1415bad066107d2.tar.gz
repo2markdown-f54df9fd6d50030beee064bfd1415bad066107d2.zip
Extract paths_from_null_separated_bytes to utils
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)?;
}
}