diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-06-02 22:11:19 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-06-06 22:19:41 -0700 |
| commit | a3f9aa9ef8657304006fcbe4759a263720b8592c (patch) | |
| tree | 25003ae61b9ce3227589e87dbd3b1b077ef4d399 /src/libnative/io | |
| parent | b830b4b86b39173843a2d660727b9e1854fe8bfb (diff) | |
rtio: Remove usage of `Path`
The rtio interface is a thin low-level interface over the I/O subsystems, and the `Path` type is a little too high-level for this interface.
Diffstat (limited to 'src/libnative/io')
| -rw-r--r-- | src/libnative/io/file_unix.rs | 10 | ||||
| -rw-r--r-- | src/libnative/io/file_win32.rs | 6 | ||||
| -rw-r--r-- | src/libnative/io/mod.rs | 4 |
3 files changed, 10 insertions, 10 deletions
diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs index b10284a3b6c..3182b061e52 100644 --- a/src/libnative/io/file_unix.rs +++ b/src/libnative/io/file_unix.rs @@ -361,17 +361,17 @@ pub fn mkdir(p: &CString, mode: io::FilePermission) -> IoResult<()> { })) } -pub fn readdir(p: &CString) -> IoResult<Vec<Path>> { +pub fn readdir(p: &CString) -> IoResult<Vec<CString>> { use libc::{dirent_t}; use libc::{opendir, readdir_r, closedir}; - fn prune(root: &CString, dirs: Vec<Path>) -> Vec<Path> { + fn prune(root: &CString, dirs: Vec<Path>) -> Vec<CString> { let root = unsafe { CString::new(root.with_ref(|p| p), false) }; let root = Path::new(root); dirs.move_iter().filter(|path| { path.as_vec() != bytes!(".") && path.as_vec() != bytes!("..") - }).map(|path| root.join(path)).collect() + }).map(|path| root.join(path).to_c_str()).collect() } extern { @@ -431,7 +431,7 @@ pub fn chown(p: &CString, uid: int, gid: int) -> IoResult<()> { })) } -pub fn readlink(p: &CString) -> IoResult<Path> { +pub fn readlink(p: &CString) -> IoResult<CString> { let p = p.with_ref(|p| p); let mut len = unsafe { libc::pathconf(p, libc::_PC_NAME_MAX) }; if len == -1 { @@ -446,7 +446,7 @@ pub fn readlink(p: &CString) -> IoResult<Path> { n => { assert!(n > 0); unsafe { buf.set_len(n as uint); } - Ok(Path::new(buf)) + Ok(buf.as_slice().to_c_str()) } } } diff --git a/src/libnative/io/file_win32.rs b/src/libnative/io/file_win32.rs index 4f1f3b3ca26..2cf54ab4007 100644 --- a/src/libnative/io/file_win32.rs +++ b/src/libnative/io/file_win32.rs @@ -347,16 +347,16 @@ pub fn mkdir(p: &CString, _mode: io::FilePermission) -> IoResult<()> { }) } -pub fn readdir(p: &CString) -> IoResult<Vec<Path>> { +pub fn readdir(p: &CString) -> IoResult<Vec<CString>> { use std::rt::libc_heap::malloc_raw; - fn prune(root: &CString, dirs: Vec<Path>) -> Vec<Path> { + fn prune(root: &CString, dirs: Vec<Path>) -> Vec<CString> { let root = unsafe { CString::new(root.with_ref(|p| p), false) }; let root = Path::new(root); dirs.move_iter().filter(|path| { path.as_vec() != bytes!(".") && path.as_vec() != bytes!("..") - }).map(|path| root.join(path)).collect() + }).map(|path| root.join(path).to_c_str()).collect() } extern { diff --git a/src/libnative/io/mod.rs b/src/libnative/io/mod.rs index 240b87fda08..a17a683646a 100644 --- a/src/libnative/io/mod.rs +++ b/src/libnative/io/mod.rs @@ -232,7 +232,7 @@ impl rtio::IoFactory for IoFactory { fn fs_rename(&mut self, path: &CString, to: &CString) -> IoResult<()> { file::rename(path, to) } - fn fs_readdir(&mut self, path: &CString, _flags: c_int) -> IoResult<Vec<Path>> { + fn fs_readdir(&mut self, path: &CString, _flags: c_int) -> IoResult<Vec<CString>> { file::readdir(path) } fn fs_lstat(&mut self, path: &CString) -> IoResult<io::FileStat> { @@ -241,7 +241,7 @@ impl rtio::IoFactory for IoFactory { fn fs_chown(&mut self, path: &CString, uid: int, gid: int) -> IoResult<()> { file::chown(path, uid, gid) } - fn fs_readlink(&mut self, path: &CString) -> IoResult<Path> { + fn fs_readlink(&mut self, path: &CString) -> IoResult<CString> { file::readlink(path) } fn fs_symlink(&mut self, src: &CString, dst: &CString) -> IoResult<()> { |
