2 unstable releases
Uses new Rust 2024
new 0.2.0 | May 3, 2025 |
---|---|
0.1.0 | Mar 22, 2025 |
#833 in Encoding
62 downloads per month
18KB
163 lines
Filename sanitizer.
Supported OS:
- Windows
- Linux (unix)
- MAC
Given a filename, escape the filename so that it is allowed by the OS.
The main functions of this crate are escape_str
and replace_escape
which will take string as input, and return modified version that can be
used as filename:
use filesan::{escape_str, Mode};
// Unix support
assert_eq!(
escape_str("\x00hello/the_re.txt:.", '_', Mode::UNIX),
"_00hello_2Fthe_5Fre.txt:."
);
// Windows support
assert_eq!(
escape_str("\x00hello/the_re.txt:.", '_', Mode::WINDOWS),
"_00hello_2Fthe_5Fre.txt_3A_2E"
);
// MACOS support
assert_eq!(
escape_str("\x00hello/the_re.txt:.", '_', Mode::MAC),
"_00hello_2Fthe_5Fre.txt_3A."
);
You can use Mode::SYSTEM
to get your current target system. See
documentation of escape_str
and replace_escape
for more info.
filesan
Filename sanitizer.
Given a filename, escape the filename so that it is allowed by OS. For more info and examples see documentation.
Links
- Author: BonnyAD9
- GitHub: BonnyAD9/filesan
- Package: crates.io
- Documentation: docs.rs
- My Website: bonnyad9.github.io
Dependencies
~105KB