rusty-files

Crates.iorusty-files
lib.rsrusty-files
version0.1.0
sourcesrc
created_at2023-09-12 07:36:58.516455
updated_at2023-09-12 07:36:58.516455
descriptionRusty files is a simple collection of file functions that I use in my projects.
homepage
repositoryhttps://github.com/malezjaa/rusty-files
max_upload_size
id970486
size22,435
malezjaa (malezjaa)

documentation

README

rusty-files

Rusty files is a simple collection of file functions that I use in my projects.

Instalation

cargo install rusty-files

Functons

delete_dir_contents - Recursively deletes all files and directories within a directory.
Arguments
  • dir_path - A Path reference to the directory to delete the contents of.
use rusty_files::delete_dir_contents;
use std::path::Path;

fn main() {
    let dir_path = Path::new("path/to/dir");
    delete_dir_contents(&dir_path);
}
check_if_path_exists - Checks if a file or directory exists at the given path.
Arguments
  • path - A Path reference to the file or directory to check for existence.
Returns

A Result containing a bool indicating whether the file or directory exists (true) or not (false), or an std::io::Error if an I/O error occurred.

use rusty_files::check_if_path_exists;
use std::path::Path;

fn main() {
   let path = Path::new("path/to/file");
   let path_exists = check_if_path_exists(&path).unwrap();
   println!("{}", path_exists);

Authors

Badges

MIT License

GitHub Sponsors

Commit count: 3

cargo fmt