Expand description
§use-file-name
Practical file-name utility primitives for RustUse.
§Experimental
use-file-name is experimental while the use-fs workspace remains below 0.3.0.
§Example
use use_file_name::{is_hidden_file_name, sanitize_file_name};
assert!(is_hidden_file_name(".gitignore"));
assert_eq!(sanitize_file_name("report?.txt"), "report-.txt");§Scope
- file-name extraction from path-like input
- reserved-name detection
- unsafe-character handling
- lightweight sanitization and normalization
§Non-goals
- locale-aware transliteration
- filesystem I/O
- universal security guarantees across all filesystems
§License
Licensed under either of the following, at your option:
- Apache License, Version 2.0
- MIT license
Structs§
- File
Name - A string-backed file name.
Functions§
- file_
name - Extracts the final file-name segment from a path-like input.
- has_
reserved_ file_ name - Returns
truewhen the extracted file name is a reserved Windows name. - is_
hidden_ file_ name - Returns
truewhen the extracted file name is a hidden dotfile. - is_
safe_ file_ name - Returns
truewhen the extracted file name avoids reserved names and unsafe characters. - normalize_
file_ name - Normalizes a file name by trimming surrounding whitespace.
- remove_
unsafe_ file_ name_ chars - Removes unsafe characters and control characters from a file name.
- replace_
unsafe_ file_ name_ chars - Replaces unsafe characters and control characters with a safe replacement.
- sanitize_
file_ name - Sanitizes a file name by trimming, replacing unsafe characters, and disarming reserved names.