Crate brown[−][src]
Functions
The creation of alibrary is always a safe operation i.e in case the folder already exist it will return an error. Keep in mind that thorugh out this library the you do not need to add “./”, it is added automatically
This function will create a file at given path as long as the file does not exist already. In case the file aready exists it will return an error and will not over write the file. Its operation is safe. You need to give a complete file path : i.e file path + file name + extention. However you do not need to add “./” before the path, that will be added automatically.
The create_file_brute function is not safe. It means that it will create a new file even if the old one exists. If this is not what you want you should try create_file.
The get_dirs will get all the directories from a directory
leaving out the files.
It will return error if no directory is found thus
the user does not have to check if the returned vec has
some values or not.
Do not include the “./” before the dir_path
get_entries will get all the entries from a directory may it be files , folders or others. If there is no entry in the said direcotry i.e there is no file or folder etc in it, in that case it will return an error. This will save the user from checking every time the returned vec if it has entries or not. The dir_path should not have “./” and should not be above the current working folder
The get_ext function will take a DirEntry object and return the file extention. This saves us a lot of efforts and conversion between types.
The get_file_name takes a DirEntry and return its file name with out the extentions.
The get_files will get all the files from a folder leaving2 out the directories. It will return error if no file is found thus the user does not have to check if the returned vec has some values or not.
The get_files_by_ext is just like get_files but it get files based on their extention. Do not add “.” (the dot) with file extention Example:: “md” , “html” , “txt” etc Do not include the “./” before the dir_path
The get_read_dir will return “ReadDir” struct from Rust which is a iterator over the directory
We can directly get is_dir function using DirEntry. This saves us digging down two levels.
The Rust std::fs::DirEntry path object has “exists” however this function takes a &str and converts that into path thus is useful when the DirEntry object has not been obtained.
The remove_dir funtion will remove a directory only of its empty. Its operation is safe. This fn should be used normally unless brute removal is required
The remove_dir_brute fn will delete a folder even if it has other files and folders. USE WITH CAUTION!!
The remove_file method can delete the file as per the given path.