feat: v0.3.3, optimize code
This commit is contained in:
11
src/util.rs
11
src/util.rs
@@ -1,15 +1,22 @@
|
||||
use std::{fs, io};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use base64::Engine;
|
||||
use base64::engine::general_purpose;
|
||||
use rand::random;
|
||||
use rust_util::{simple_error, warning, XResult};
|
||||
use rust_util::{information, simple_error, warning, XResult};
|
||||
use zeroize::Zeroize;
|
||||
|
||||
use crate::consts::TINY_ENC_FILE_EXT;
|
||||
|
||||
pub fn remove_file_with_msg(path: &PathBuf) {
|
||||
match fs::remove_file(path) {
|
||||
Err(e) => warning!("Remove file: {} failed: {}", path.display(), e),
|
||||
Ok(_) => information!("Remove file: {} succeed", path.display()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_file_name(path: &Path) -> String {
|
||||
let path_display = format!("{}", path.display());
|
||||
if path_display.contains('/') {
|
||||
|
||||
Reference in New Issue
Block a user