diff options
Diffstat (limited to 'src/devices/file/operations.rs')
-rw-r--r-- | src/devices/file/operations.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/devices/file/operations.rs b/src/devices/file/operations.rs index f33509b..0593ac8 100644 --- a/src/devices/file/operations.rs +++ b/src/devices/file/operations.rs @@ -1,11 +1,13 @@ use std::io::ErrorKind; use std::path::Path; + +/// Returns true if an entry already exists at the given path. pub fn entry_exists(source: &Path) -> bool { std::fs::metadata(source).is_ok() } -// Delete a file or folder, returning true if successful. +/// Delete an entry, returning true if successful. pub fn delete_entry(source: &Path) -> bool { match std::fs::remove_file(source) { Ok(_) => true, @@ -23,6 +25,7 @@ pub fn delete_entry(source: &Path) -> bool { } } +/// Move an entry from one location to another, returning true if successful. pub fn move_entry(source: &Path, destination: &Path) -> bool { if !entry_exists(source) || entry_exists(destination) { return false; @@ -30,6 +33,7 @@ pub fn move_entry(source: &Path, destination: &Path) -> bool { std::fs::rename(source, destination).is_ok() } +/// Create a new file if it doesn't already exist, returning true if successful. pub fn create_file(destination: &Path) -> bool { if entry_exists(destination) { false |