# Qfile
Crate for accessing a file by path, case insensitive. Automatic detection, create a path with a new file or open an existing file.
# Examples ```rust //add_path() //Constructor for adding a file path. //After using the write() or read() methods, and if Ok(), //we get the correct path, which will be used as a cache when we reuse
// the real file path: `./FOLDER/folder/File.txt`
let mut file = QFilePack::add_path("./folder/folder/file.txt");
{
// The real path is searched after the first method call.
// It's stored in the structure
file.write("text_1").unwrap();
}
// we get the saved path right away
file.write("text_2").unwrap();
println!("{}",file.read().unwrap());
//output: text_1text_2
```
```rust use qfile::QFilePack; use std::fs::File;
// the real file path: `./new_FILE.txt`
let mut file = QFilePack::add_path("./new_file.txt").file().unwrap();
// Get the file directly
// You can use the function to retrieve data
// in bytes format or use it for any other option
assert_eq!(file.metadata().unwrap().is_file(), true);
```
./folder/folder/file.txt
.\\folder\\folder\\file.txt
\
> D:\\folder\\folder\\file.txt
Creates a new path with file. Writes new data to an empty file
```rust let mut file = QFilePack::addpath("./newfile.txt"); { file.write(":D").unwrap(); } file.write(":D").unwrap(); assert_eq!(file.read().unwrap(),":D:D");
``` - If the path exists, we work with the file (case insensitive)
The path we specified:
./FLDR/FlDr/file.TXT
\ real path :./fldr/fldr/file.txt
\ Result :./fldr/fldr/file.txt
If the file/path is not found, creates a new path with the file (if initial path exists)
The path we specified:
./fldr/fldr_new/file.txt
\ real path :./fldr
\ Result :./fldr/fldr_new/file.txt
but if the initial path is different case of letters and a new file/folder is specified in the path, then a new path is created with the file
The path we specified:
./FLDR/fldr_new/file.TXT
\ real path :./fldr
\ Result :\./fldr
\./FLDR/fldr_new/file.TXT