Skip to content

Commit ffe5d3f

Browse files
committed
use types from 'struct stat' instead 'struct statx'
1 parent 39fc803 commit ffe5d3f

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/metadata.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ impl Metadata {
4747
self.stat.st_size as u64
4848
}
4949
/// Return low level file type, if available
50-
pub fn file_type(&self) -> Option<u32> {
51-
Some(self.stat.st_mode as u32 & libc::S_IFMT as u32)
50+
pub fn file_type(&self) -> Option<libc::mode_t> {
51+
Some(self.stat.st_mode & libc::S_IFMT)
5252
}
5353
/// Return device node, if available
54-
pub fn ino(&self) -> Option<u64> {
55-
Some(self.stat.st_ino as u64)
54+
pub fn ino(&self) -> Option<libc::ino_t> {
55+
Some(self.stat.st_ino)
5656
}
5757
/// Return device node major of the file, if available
5858
pub fn dev_major(&self) -> Option<u32> {
@@ -77,32 +77,32 @@ impl Metadata {
7777
}
7878
}
7979
/// Return preferered I/O Blocksize, if available
80-
pub fn blksize(&self) -> Option<u32> {
81-
Some(self.stat.st_blksize as u32)
80+
pub fn blksize(&self) -> Option<libc::blksize_t> {
81+
Some(self.stat.st_blksize)
8282
}
8383
/// Return the number of 512 bytes blocks, if available
84-
pub fn blocks(&self) -> Option<u64> {
85-
Some(self.stat.st_blocks as u64)
84+
pub fn blocks(&self) -> Option<libc::blkcnt_t> {
85+
Some(self.stat.st_blocks)
8686
}
8787
/// Returns file size (same as len() but Option), if available
88-
pub fn size(&self) -> Option<u64> {
89-
Some(self.stat.st_size as u64)
88+
pub fn size(&self) -> Option<libc::off_t> {
89+
Some(self.stat.st_size)
9090
}
9191
/// Returns number of hard-links, if available
92-
pub fn nlink(&self) -> Option<u32> {
93-
Some(self.stat.st_nlink as u32)
92+
pub fn nlink(&self) -> Option<libc::nlink_t> {
93+
Some(self.stat.st_nlink)
9494
}
9595
/// Returns user id, if available
96-
pub fn uid(&self) -> Option<u32> {
97-
Some(self.stat.st_uid as u32)
96+
pub fn uid(&self) -> Option<libc::uid_t> {
97+
Some(self.stat.st_uid)
9898
}
9999
/// Returns group id, if available
100-
pub fn gid(&self) -> Option<u32> {
101-
Some(self.stat.st_gid as u32)
100+
pub fn gid(&self) -> Option<libc::gid_t> {
101+
Some(self.stat.st_gid)
102102
}
103103
/// Returns mode bits, if available
104-
pub fn file_mode(&self) -> Option<u32> {
105-
Some(self.stat.st_mode as u32 & 0o7777)
104+
pub fn file_mode(&self) -> Option<libc::mode_t> {
105+
Some(self.stat.st_mode & 0o7777)
106106
}
107107
/// Returns last access time, if available
108108
pub fn atime(&self) -> Option<SystemTime> {

0 commit comments

Comments
 (0)