mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-13 00:26:53 +00:00
review disk
This commit is contained in:
+32
-1
@@ -1,6 +1,11 @@
|
||||
use std::{fs::Metadata, os::unix::fs::MetadataExt};
|
||||
use std::{fs::Metadata, path::Path};
|
||||
|
||||
use tokio::{fs, io};
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn same_file(f1: &Metadata, f2: &Metadata) -> bool {
|
||||
use os::unix::fs::MetadataExt;
|
||||
|
||||
if f1.dev() != f2.dev() {
|
||||
return false;
|
||||
}
|
||||
@@ -22,3 +27,29 @@ pub fn same_file(f1: &Metadata, f2: &Metadata) -> bool {
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn same_file(f1: &Metadata, f2: &Metadata) -> bool {
|
||||
if f1.permissions() != f2.permissions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if f1.file_type() != f2.file_type() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if f1.len() != f2.len() {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub async fn access(path: impl AsRef<Path>) -> io::Result<()>{
|
||||
fs::metadata(path).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn make_dir_all(path: impl AsRef<Path>) -> io::Result<()>{
|
||||
fs::create_dir_all(path.as_ref()).await
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
const GLOBAL_DIR_SUFFIX: &str = "__XLDIR__";
|
||||
|
||||
const SLASH_SEPARATOR: &str = "/";
|
||||
pub const SLASH_SEPARATOR: &str = "/";
|
||||
|
||||
pub fn has_suffix(s: &str, suffix: &str) -> bool {
|
||||
if cfg!(target_os = "windows") {
|
||||
|
||||
Reference in New Issue
Block a user