Skip to content

Commit

Permalink
Rollup merge of rust-lang#22744 - alexcrichton:issue-22738, r=aturon
Browse files Browse the repository at this point in the history
 Currently we have a `set_mode` mutator, so this just adds the pairing of a
`mode` accessor to read the value.

Closes rust-lang#22738
  • Loading branch information
Manishearth committed Feb 25, 2015
2 parents ecaf74a + 537d694 commit 1f2b3eb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libstd/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ impl FromInner<fs_imp::FilePermissions> for Permissions {
}
}

impl AsInner<fs_imp::FilePermissions> for Permissions {
fn as_inner(&self) -> &fs_imp::FilePermissions { &self.0 }
}

impl Iterator for ReadDir {
type Item = io::Result<DirEntry>;

Expand Down
3 changes: 3 additions & 0 deletions src/libstd/sys/unix/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,13 @@ impl OsStrExt for OsStr {

// Unix-specific extensions to `Permissions`
pub trait PermissionsExt {
fn mode(&self) -> i32;
fn set_mode(&mut self, mode: i32);
}

impl PermissionsExt for Permissions {
fn mode(&self) -> i32 { self.as_inner().mode() }

fn set_mode(&mut self, mode: i32) {
*self = FromInner::from_inner(FromInner::from_inner(mode));
}
Expand Down
1 change: 1 addition & 0 deletions src/libstd/sys/unix/fs2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl FilePermissions {
self.mode |= 0o222;
}
}
pub fn mode(&self) -> i32 { self.mode as i32 }
}

impl FromInner<i32> for FilePermissions {
Expand Down

0 comments on commit 1f2b3eb

Please sign in to comment.