Gid, uid to u32

This commit is contained in:
ChristianVisintin
2020-11-15 11:18:35 +01:00
parent 1139eb2c17
commit 13fb42078b
2 changed files with 11 additions and 9 deletions

View File

@@ -49,8 +49,8 @@ pub struct FsDirectory {
pub creation_time: SystemTime,
pub readonly: bool,
pub symlink: Option<PathBuf>, // UNIX only
pub user: Option<String>, // UNIX only
pub group: Option<String>, // UNIX only
pub user: Option<u32>, // UNIX only
pub group: Option<u32>, // UNIX only
pub unix_pex: Option<(u8, u8, u8)>, // UNIX only
}
@@ -69,7 +69,7 @@ pub struct FsFile {
pub ftype: Option<String>, // File type
pub readonly: bool,
pub symlink: Option<PathBuf>, // UNIX only
pub user: Option<String>, // UNIX only
pub group: Option<String>, // UNIX only
pub user: Option<u32>, // UNIX only
pub group: Option<u32>, // UNIX only
pub unix_pex: Option<(u8, u8, u8)>, // UNIX only
}

View File

@@ -32,7 +32,7 @@ extern crate users;
#[cfg(any(unix, macos, linux))]
use std::os::unix::fs::MetadataExt;
#[cfg(any(unix, macos, linux))]
use users::{get_group_by_gid, get_user_by_uid};
// use users::{get_group_by_gid, get_user_by_uid};
// Locals
use crate::fs::{FsDirectory, FsEntry, FsFile};
@@ -259,6 +259,7 @@ impl Localhost {
let path: PathBuf = entry.path();
let attr: Metadata = fs::metadata(path.clone()).unwrap();
// Get user stuff
/*
let user: Option<String> = match get_user_by_uid(attr.uid()) {
Some(user) => Some(String::from(user.name().to_str().unwrap_or(""))),
None => None,
@@ -267,6 +268,7 @@ impl Localhost {
Some(group) => Some(String::from(group.name().to_str().unwrap_or(""))),
None => None,
};
*/
let file_name: String =
String::from(path.file_name().unwrap().to_str().unwrap_or(""));
// Match dir / file
@@ -284,8 +286,8 @@ impl Localhost {
Ok(p) => Some(p),
Err(_) => None,
},
user: user,
group: group,
user: Some(attr.uid()),
group: Some(attr.gid()),
unix_pex: Some(self.u32_to_mode(attr.mode())),
})
}
@@ -308,8 +310,8 @@ impl Localhost {
Ok(p) => Some(p),
Err(_) => None,
},
user: user,
group: group,
user: Some(attr.uid()),
group: Some(attr.gid()),
unix_pex: Some(self.u32_to_mode(attr.mode())),
})
}