Crate ez_fs

Source
Expand description

§ez_fs

ez_fs is a Rust library that provides convenient abstractions for working with files and directories. It aims to simplify common file and directory operations by providing easy-to-use interfaces and utilities.

§Features

  • Wrapper for std::fs types, providing a simplified and more ergonomic API.
  • Lazy-loading directory representation with the ability to cache and walk through subdirectories.
  • Flattening directories into vectors of files for easy traversal and manipulation.

§Getting Started

§Reading/Writing to Files

//open file in write-only mode
let mut file = EzFile::create("foo.txt").unwrap();
file.write_all(b"bar").unwrap();

//change to read-only
file.to_read().unwrap();

let mut buf = String::new();
file.read_to_string(&mut buf).unwrap();
assert_eq!(buf, "bar");

§Collecting Directories

//open an existing directory
let dir = EzDir::new(".", true).unwrap();

//recursively can subdirectories and collect all files
let files = dir.flatten_all();
for file in files {
    println!("{file}")
}

Structs§

EzDir
Representation of a directory. Directories are lazily evaluated, and will not be scanned until asked to.
EzFile
Representation of an open file. Wraps std::fs things such as metadata together to handle neatly.

Enums§

EzEntry
Represents an entry in a directory.