-
-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
read_dir(precompose_unicode)
This way, the returned iterator can provide dir entries that can adjust the filepath automatically depending on the value of precompose_unicode
- Loading branch information
Showing
5 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
pub use gix_features::fs::read_dir::DirEntry; | ||
|
||
pub(crate) mod function { | ||
use std::path::Path; | ||
|
||
/// List all entries in `path`, similar to [`std::fs::read_dir()`], and assure all available information | ||
/// adheres to the value of `precompose_unicode`. | ||
pub fn read_dir( | ||
path: &Path, | ||
precompose_unicode: bool, | ||
) -> std::io::Result<impl Iterator<Item = std::io::Result<super::DirEntry>>> { | ||
std::fs::read_dir(path) | ||
.map(move |it| it.map(move |res| res.map(|entry| super::DirEntry::new(entry, precompose_unicode)))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#[test] | ||
fn with_precomposed_unicode() -> crate::Result { | ||
let tmp = tempfile::tempdir()?; | ||
|
||
let precomposed = "ä"; | ||
let decomposed = "a\u{308}"; | ||
|
||
let root = tmp.path().join(decomposed); | ||
std::fs::create_dir(&root)?; | ||
std::fs::write(root.join(decomposed), &[])?; | ||
|
||
for entry in gix_fs::read_dir(&root, true)? { | ||
dbg!(entry); | ||
} | ||
|
||
assert!(false); | ||
Ok(()) | ||
} |