6 个版本 (破坏性更新)
使用旧的 Rust 2015
0.5.0 | 2023 年 7 月 31 日 |
---|---|
0.4.0 | 2022 年 5 月 7 日 |
0.3.0 | 2020 年 10 月 18 日 |
0.2.1 | 2018 年 10 月 24 日 |
0.1.0 | 2018 年 10 月 24 日 |
#78 在 解析实现
94,618 每月下载量
在 122 个 crate 中使用 (56 直接)
12KB
308 行
sanitize-filename
一个基于 Node 的 sanitize-filename 的基本文件名清理工具。
使用方法
extern crate sanitize_filename;
fn main() {
println!("{}", sanitize_filename::sanitize("some-user-defined/../../../string"));
// prints some-user-defined......string
}
您还可以配置一些基本选项
let options = sanitize_filename::Options {
truncate: true, // true by default, truncates to 255 bytes
windows: true, // default value depends on the OS, removes reserved names like `con` from start of strings on Windows
replacement: "" // str to replace sanitized chars/strings
};
let sanitized = sanitize_filename::sanitize_with_options("some-user-defined/../../../string", options);
还提供了一个基本的命令行二进制文件。使用方法
cargo install sanitize-filename
sanitize-filename my_filename.txt
Pass a file name to clean to the program (also reads STDIN)
FLAGS:
-r, --replace <r> Replacement characters
--windows, --no-windows Whether to handle filenames for Windows
--truncate, --no-truncate Whether to truncate file names to 255 bytes
依赖项
~2.8–4MB
~67K SLoC