Skip to content

Commit

Permalink
Redox: add stat methods(); support is_symlink()
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Jul 7, 2017
1 parent 696412d commit 4d58b04
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/libstd/sys/redox/ext/fs.rs
Expand Up @@ -177,6 +177,8 @@ pub trait MetadataExt {
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn mode(&self) -> u32;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn nlink(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn uid(&self) -> u32;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn gid(&self) -> u32;
Expand All @@ -194,6 +196,10 @@ pub trait MetadataExt {
fn ctime(&self) -> i64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn ctime_nsec(&self) -> i64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn blksize(&self) -> u64;
#[stable(feature = "metadata_ext", since = "1.1.0")]
fn blocks(&self) -> u64;
}

#[stable(feature = "metadata_ext", since = "1.1.0")]
Expand All @@ -207,6 +213,9 @@ impl MetadataExt for fs::Metadata {
fn mode(&self) -> u32 {
self.as_inner().as_inner().st_mode as u32
}
fn nlink(&self) -> u64 {
self.as_inner().as_inner().st_nlink as u64
}
fn uid(&self) -> u32 {
self.as_inner().as_inner().st_uid as u32
}
Expand Down Expand Up @@ -234,6 +243,12 @@ impl MetadataExt for fs::Metadata {
fn ctime_nsec(&self) -> i64 {
self.as_inner().as_inner().st_ctime_nsec as i64
}
fn blksize(&self) -> u64 {
self.as_inner().as_inner().st_blksize as u64
}
fn blocks(&self) -> u64 {
self.as_inner().as_inner().st_blocks as u64
}
}

/// Add special Redox types (block/char device, fifo and socket)
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/sys/redox/fs.rs
Expand Up @@ -119,10 +119,10 @@ impl FilePermissions {
impl FileType {
pub fn is_dir(&self) -> bool { self.is(syscall::MODE_DIR) }
pub fn is_file(&self) -> bool { self.is(syscall::MODE_FILE) }
pub fn is_symlink(&self) -> bool { false /*FIXME: Implement symlink mode*/ }
pub fn is_symlink(&self) -> bool { self.is(syscall::MODE_SYMLINK) }

pub fn is(&self, mode: u16) -> bool {
self.mode & (syscall::MODE_DIR | syscall::MODE_FILE) == mode
self.mode & syscall::MODE_TYPE == mode
}
}

Expand Down

0 comments on commit 4d58b04

Please sign in to comment.