Use chmod instead of fcntl to change file perms

This commit is contained in:
Jeremy Soller
2016-11-15 17:07:55 -07:00
parent 2e5c821619
commit 267bc54fbd

View File

@@ -387,10 +387,7 @@ pub fn rename(_old: &Path, _new: &Path) -> io::Result<()> {
} }
pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> { pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> {
let mut options = OpenOptions::new(); cvt(libc::chmod(p.to_str().unwrap(), perm.mode as usize))?;
options.read(true);
let file = File::open(p, &options)?;
cvt(libc::fcntl(file.0.raw(), libc::F_SETMODE, perm.mode as usize))?;
Ok(()) Ok(())
} }