Skip to content

Commit 2e5c821

Browse files
committed
Add set_perm
1 parent 73f24d4 commit 2e5c821

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/libstd/sys/redox/ext/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl MetadataExt for fs::Metadata {
216216
}
217217
}
218218

219-
/*
219+
/* TODO
220220
/// Add special unix types (block/char device, fifo and socket)
221221
#[stable(feature = "file_type_ext", since = "1.5.0")]
222222
pub trait FileTypeExt {

src/libstd/sys/redox/fs.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,12 @@ pub fn rename(_old: &Path, _new: &Path) -> io::Result<()> {
386386
unimplemented!();
387387
}
388388

389-
pub fn set_perm(_p: &Path, _perm: FilePermissions) -> io::Result<()> {
390-
::sys_common::util::dumb_print(format_args!("Set perm\n"));
391-
unimplemented!();
389+
pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> {
390+
let mut options = OpenOptions::new();
391+
options.read(true);
392+
let file = File::open(p, &options)?;
393+
cvt(libc::fcntl(file.0.raw(), libc::F_SETMODE, perm.mode as usize))?;
394+
Ok(())
392395
}
393396

394397
pub fn rmdir(p: &Path) -> io::Result<()> {

0 commit comments

Comments
 (0)