feat: v0.1.2, updated dependences, check file before encrypt

This commit is contained in:
2023-10-07 22:18:21 +08:00
parent 5831edb9b5
commit 0bfd25e73c
3 changed files with 63 additions and 37 deletions

View File

@@ -28,10 +28,14 @@ pub fn require_tiny_enc_file_and_exists(path: impl AsRef<Path>) -> XResult<()> {
pub fn require_file_exists(path: impl AsRef<Path>) -> XResult<()> {
let path = path.as_ref();
match fs::metadata(path) {
Ok(_) => Ok(()),
Err(_) => simple_error!("File: {} not exists", path.display()),
let metadata = match fs::metadata(path) {
Ok(metadata) => metadata,
Err(_) => return simple_error!("File: {} not exists", path.display()),
};
if !metadata.is_file() {
return simple_error!("Path: {} is not a file", path.display());
}
Ok(())
}
pub fn require_file_not_exists(path: impl AsRef<Path>) -> XResult<()> {