Skip to main content

Crate use_file_name

Crate use_file_name 

Source
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§

FileName
A string-backed file name.

Functions§

file_name
Extracts the final file-name segment from a path-like input.
has_reserved_file_name
Returns true when the extracted file name is a reserved Windows name.
is_hidden_file_name
Returns true when the extracted file name is a hidden dotfile.
is_safe_file_name
Returns true when 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.