#file-path #directory #folder #system #dealing #automatic

brown

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

2 unstable releases

0.2.0 Dec 20, 2021
0.1.9 Dec 14, 2021
0.1.5 Nov 30, 2021
0.0.9 Nov 23, 2021
0.0.0 Oct 28, 2021

#980 in Filesystem

22 downloads per month
Used in 3 crates

MIT/Apache

55KB
1.5K SLoC

Brown

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


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 API is almost final. I do not see any major changes in it.
  • More tests will be added and code will be improved; other than that the lib is complete.
  • Keep in mind that thorugh out this library you do not need to add "./" anywhere in the path, it is added automatically. However if you do add "./" before the path that does not cause an error now (in past version it did).
  • The word folder" and "directory" are used interchangebaly;there is no difference between a "folder" and "directory" in the documentation. They are both same.*

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());

  }

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

Dependencies

~285–750KB
~18K SLoC