Skip to main content

Module utils

Module utils 

Source
Expand description

Generic utility functions for the crate.

This module contains miscellaneous utility functions that don’t fit into more specific modules. Functions are organized into categories:

  • Generic utils: String parsing, case-insensitive operations, line/column calculations
  • Path utils: File and folder enumeration, path sanitization, absolute path conversion
  • Time utils: File modification time queries, current time helpers
  • Pelite utils: PE (Windows executable) file inspection
  • VWise utils: WWise audio hash generation
  • Filename sanitization: Windows-compatible filename cleaning
  • Decoder utils: Size mismatch validation for binary decoders

Constants§

DEFAULT_FILENAME
Default filename used when sanitization results in an empty name.
INVALID_CHARACTERS_WINDOWS
Windows-invalid filename characters.

Functions§

closest_valid_char_byte
Finds the closest valid UTF-8 character boundary at or after the given byte position.
current_time
Returns the current Unix timestamp in seconds.
files_from_subdir
Returns all files in a directory, optionally scanning subdirectories recursively.
files_in_folder_from_newest_to_oldest
Returns all files in a directory sorted by modification time (newest first).
final_folders_from_subdir
Returns all leaf directories (folders with no subfolders) in a directory tree.
hash_vwise
Generates a WWise audio hash from a filename.
last_modified_time_from_file
Returns the last modification time of a file as a Unix timestamp.
last_modified_time_from_files
Returns the most recent modification time from a list of file paths.
line_column_from_string_pos
Converts a byte position in a string to a line and column number.
oldest_file_in_folder
Returns the oldest file in a directory based on modification time.
parse_str_as_bool
Parses a string to a boolean value.
path_to_absolute_path
Converts a path to an absolute PathBuf, optionally stripping Windows UNC prefix.
path_to_absolute_string
Converts a path to an absolute path string, stripping Windows UNC prefix if present.
sanitize_filename
Sanitizes a filename by replacing invalid Windows characters.
sanitize_path
Sanitizes a file path by cleaning the filename component.
starts_with_case_insensitive
Checks if a string starts with another string (case-insensitive).