#file #file-system #system

brown

A simple library that makes dealing with Rust file system a breeze

5 releases

Uses new Rust 2021

new 0.1.4 Nov 29, 2021
0.1.3 Nov 26, 2021
0.0.9 Nov 23, 2021
0.0.0 Oct 28, 2021
Download history 15/week @ 2021-10-25 71/week @ 2021-11-01 64/week @ 2021-11-08 19/week @ 2021-11-15 82/week @ 2021-11-22

86 downloads per month
Used in hulk

MIT/Apache

45KB
1K SLoC

Brown

A simple library that makes dealing with Rust file system a breeze.


Any one who has done any file system related project in Rust will know that the Rust file system (std::fs) is a bit wonky (so say the least).

Brown library exports helpful functions which gives you a very simple API for creating managin and manipulating files,folder etc in the current working folder.

  • The tasks feature is experimental.
  • Keep in mind that thorugh out this library you do not need to add "./", it is added automatically.
  • Please wait till version 1.0 for use in production

Example

use brown;

pub fn main(){
  // create a folder (parent folder) for rest of the tests
  let p_dir = brown::create_dir("parent");
  assert!(p_dir.is_ok());

  // create file safely
  let md_file = brown::create_file("parent/md_file.md");
  assert!(md_file.is_ok());
  
  // Will over write a file even if exists already.
  let html_file = brown::create_file_brute("parent/html_file.html");
  assert!(html_file.is_ok());
  
  // create a folder inside previously created parent folder 
  let test_folder = brown::create_dir("parent/test_folder");
  assert!(test_folder.is_ok());

  // This will just get the files from the given folder root.It returns a Vec of DirEntry objects (std::fs::DirEntry). Many fn in this lib consume DirEntry object.  
  let all_files = brown::get_files("parent");
  assert!(all_files.is_ok());
  
  // This will just get the folders from the given folder root. 
  let all_dirs = brown::get_dirs("parent");
  assert!(all_dirs.is_ok());
  
  // This will just get the files with .md extention from the given folder root.
  let all_md_files = brown::get_files_by_ext("parent","md");
  assert!(all_md_files.is_ok());
  // This will get all entries from a folder
  let all_entries = brown::get_entries("parent");
  assert!(all_entries.is_ok());

  }

Please note that there is no difference between a "folder" and "directory" in the documentation. The are both same. Do not add the ./ anywhere in the paths, this will be added automatically. There are no relative paths used.

Incase you have any issues with the library, let me know here https://github.com/skillzaa/brown/issues

Please be in touch

My twitter handle is :: @rusthulk

No runtime deps