Add set_perm

This commit is contained in:
Jeremy Soller 2016-11-15 16:12:30 -07:00
parent 73f24d47de
commit 2e5c821619
2 changed files with 7 additions and 4 deletions

View file

@ -216,7 +216,7 @@ impl MetadataExt for fs::Metadata {
}
}
/*
/* TODO
/// Add special unix types (block/char device, fifo and socket)
#[stable(feature = "file_type_ext", since = "1.5.0")]
pub trait FileTypeExt {

View file

@ -386,9 +386,12 @@ pub fn rename(_old: &Path, _new: &Path) -> io::Result<()> {
unimplemented!();
}
pub fn set_perm(_p: &Path, _perm: FilePermissions) -> io::Result<()> {
::sys_common::util::dumb_print(format_args!("Set perm\n"));
unimplemented!();
pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> {
let mut options = OpenOptions::new();
options.read(true);
let file = File::open(p, &options)?;
cvt(libc::fcntl(file.0.raw(), libc::F_SETMODE, perm.mode as usize))?;
Ok(())
}
pub fn rmdir(p: &Path) -> io::Result<()> {