The crate for working with files without taking into account the case of the path. Automatic detection, create a path with a new file or open an existing file.
# Usage
Add this to your Cargo.toml:
toml
[dependencies]
qfile="0.1.0"
# Example
use qfile::{file_read, file_write, Flag};
fn main() {
file_write(
"./Folder1/NewFolder1/file_new.txt",
"TEXT TEXT TEXT",
Flag::Auto,
)
.unwrap();
println!("{}",file_read("./Folder1/NewFolder1/file_new.txt").unwrap());
}
# Paths syntax - Windows
".\\folder\\\folder\\file.txt"
- linux"./folder/folder/file.txt"
- macos (doesn't work with files with '/', "x/y/z.txt" in the name on macos)"./folder/folder/file.txt"
Creates a new path with file. Writes new data to an empty file
```
let path = "./Folder1/NewFolder1/file_new.txt";
assert_eq!(file_write(path, "ok", Flag::New).unwrap(), file_read(path).unwrap());
```
If the path exists, regardless of the case, we work with the file (Flag::Old)
The path we specified:
"/Folder1/folDER2/file.TXT"
\ real path :"/Folder1/Folder2/file.txt"
\ Result :"/Folder1/Folder2/file.txt"
(Flag::New)
The path we specified:
"/Folder1/newFolder/file.TXT"
\ real path :"/Folder1/newFolder/file.txt"
\ Result :"/Folder1/newFolder/file.txt"
but if the initial path is case different, then a new path with the file is created (Flag::New)
The path we specified:
"/folder1/newFolder/file.TXT"
\ real path :"/folder1/newFolder/file.txt"
\ Result :"/folder1/newFolder/file.txt"
Examples
``` let path = "./Folder1/notexistingfolder/file_new.txt";
asserteq!(filewrite(path, "ok", Flag::Auto).unwrap(), file_read(path).unwrap()); ```
Finds an already existing file. Appends new data to an existing file
``` let path = "./Folder1/NewFolder1/file_new.txt";
asserteq!(filewrite(path, "ok", Flag::Old).unwrap(), file_read(path).unwrap()); ```