diff options
author | Carl Lerche <me@carllerche.com> | 2015-02-26 17:45:01 -0800 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2015-02-27 11:14:38 -0800 |
commit | e8a58c83a50ef7e197767b5a491050ae91c9e503 (patch) | |
tree | c36a21e65ed26e7610d2182821a4a23f9dc4ee3f /src/sys/stat.rs | |
parent | 8a7cd5675d38365d96e322693f455b2cd7fea6e5 (diff) | |
download | nix-e8a58c83a50ef7e197767b5a491050ae91c9e503.zip |
Further SockAddr & NixPath cleanup
Diffstat (limited to 'src/sys/stat.rs')
-rw-r--r-- | src/sys/stat.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/sys/stat.rs b/src/sys/stat.rs index 1397ad24..f51fec4a 100644 --- a/src/sys/stat.rs +++ b/src/sys/stat.rs @@ -1,12 +1,12 @@ pub use libc::dev_t; pub use libc::stat as FileStat; -use std::fmt; -use std::mem; +use {NixError, NixResult, NixPath, AsExtStr,from_ffi}; use errno::Errno; -use libc::mode_t; use fcntl::Fd; -use {NixError, NixResult, NixPath, from_ffi}; +use libc::mode_t; +use std::fmt; +use std::mem; mod ffi { use libc::{c_char, c_int, mode_t, dev_t}; @@ -57,10 +57,10 @@ impl fmt::Debug for SFlag { } } -pub fn mknod<P: NixPath>(path: P, kind: SFlag, perm: Mode, dev: dev_t) -> NixResult<()> { - let res = try!(path.with_nix_path(|ptr| { +pub fn mknod<P: ?Sized + NixPath>(path: &P, kind: SFlag, perm: Mode, dev: dev_t) -> NixResult<()> { + let res = try!(path.with_nix_path(|osstr| { unsafe { - ffi::mknod(ptr, kind.bits | perm.bits() as mode_t, dev) + ffi::mknod(osstr.as_ext_str(), kind.bits | perm.bits() as mode_t, dev) } })); from_ffi(res) @@ -79,11 +79,11 @@ pub fn umask(mode: Mode) -> Mode { Mode::from_bits(prev).expect("[BUG] umask returned invalid Mode") } -pub fn stat<P: NixPath>(path: P) -> NixResult<FileStat> { +pub fn stat<P: ?Sized + NixPath>(path: &P) -> NixResult<FileStat> { let mut dst = unsafe { mem::uninitialized() }; - let res = try!(path.with_nix_path(|ptr| { + let res = try!(path.with_nix_path(|osstr| { unsafe { - ffi::stat(ptr, &mut dst as *mut FileStat) + ffi::stat(osstr.as_ext_str(), &mut dst as *mut FileStat) } })); |