FSPP
FSPP stands for Filesystem++, and it is exactly what the name implies. It is a better, more high-level library for filesystem tasks. It also converts forward/backward slashes, depending on the OS.
Examples:
use *;
FSPP stands for Filesystem++, and it is exactly what the name implies. It is a better, more high-level library for filesystem tasks. It also converts forward/backward slashes, depending on the OS.
use fspp::*;
fn main() {
let path = Path::new("my_file.txt"); // FSPP path struct.
if path.exists() == { // Another way to see if a path exists is by seeing if the .path_type() method returns PathType::Invalid
if path.path_type() == PathType::Directory {
println!("Say whaaaat? The file is actually a directory?");
}
else if path.path_type() == PathType::File {
let contents: String = file::read(&path).unwrap();
println!("{}", contents);
}
}
else {
println!("File not found!");
}
}