feat: v0.3.3, optimize code

This commit is contained in:
2023-10-15 11:29:31 +08:00
parent 2624b0fa64
commit b268d88e3c
5 changed files with 58 additions and 54 deletions

View File

@@ -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('/') {