file_tree 0.1.1

Creates a directory structure suitable for storing large numbers of files, and optionally deletes the created directory and files when dropped.
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented1 out of 1 items with examples
  • Size
  • Source code size: 20.4 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 273.2 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • pnnl/file_tree
    1 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • aaronrphillips

file_tree

Creates and manages a directory structure suitable for storing large numbers of files (up to 1 trillion).

Usage

Add this to your Cargo.toml:

[dependencies]
file_tree = "0.1.1"

Examples

Use FileTree::new(false) to create a temporary structure that will be deleted when the created struct is dropped.

Calls to get_new_file() will generate a new PathBuf. The parent directory will exist, but get_new_file() will not actually create the file.

Use get_root() to retrieve the base path for the created directory structure.

extern crate file_tree;

use file_tree::FileTree;

fn main() {
    let mut file_tree = FileTree::new(false).unwrap();

    let writeable_path = file_tree.get_new_file().unwrap();
    assert_eq!(
        writeable_path,
        file_tree.get_root().join("000/000/000/000000000000")
    );

    let writeable_path_2 = file_tree.get_new_file().unwrap();
    assert_eq!(
        writeable_path_2,
        file_tree.get_root().join("000/000/000/000000000001")
    );
}