mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-16 17:14:36 +01:00
Fix clippy lints
This commit is contained in:
@@ -5,28 +5,28 @@ pub fn rename(path: String, new_name: String) {
|
||||
let mut new_path = path.clone();
|
||||
|
||||
// Check if file/folder to replace exists
|
||||
if !fs::metadata(&path).is_ok() {
|
||||
if fs::metadata(&path).is_err() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if path uses forward or back slashes
|
||||
if new_path.contains("\\") {
|
||||
new_path = path.replace("\\", "/");
|
||||
if new_path.contains('\\') {
|
||||
new_path = path.replace('\\', "/");
|
||||
}
|
||||
|
||||
let path_replaced = &path.replace(&new_path.split("/").last().unwrap(), &new_name);
|
||||
let path_replaced = &path.replace(&new_path.split('/').last().unwrap(), &new_name);
|
||||
|
||||
fs::rename(path, &path_replaced).unwrap();
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn dir_exists(path: &str) -> bool {
|
||||
return fs::metadata(&path).is_ok();
|
||||
fs::metadata(&path).is_ok()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn dir_is_empty(path: &str) -> bool {
|
||||
return fs::read_dir(&path).unwrap().count() == 0;
|
||||
fs::read_dir(&path).unwrap().count() == 0
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
Reference in New Issue
Block a user