feat: v0.1.2, updated dependences, check file before encrypt
This commit is contained in:
10
src/util.rs
10
src/util.rs
@@ -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<()> {
|
||||
|
||||
Reference in New Issue
Block a user