}))
}
-pub fn readdir(p: &CString) -> IoResult<~[Path]> {
+pub fn readdir(p: &CString) -> IoResult<Vec<Path>> {
use libc::{dirent_t};
use libc::{opendir, readdir_r, closedir};
- fn prune(root: &CString, dirs: ~[Path]) -> ~[Path] {
+ fn prune(root: &CString, dirs: Vec<Path>) -> Vec<Path> {
let root = unsafe { CString::new(root.with_ref(|p| p), false) };
let root = Path::new(root);
let dir_ptr = p.with_ref(|buf| unsafe { opendir(buf) });
if dir_ptr as uint != 0 {
- let mut paths = ~[];
+ let mut paths = vec!();
let mut entry_ptr = 0 as *mut dirent_t;
while unsafe { readdir_r(dir_ptr, ptr, &mut entry_ptr) == 0 } {
if entry_ptr.is_null() { break }
}
}
}
-
})
}
-pub fn readdir(p: &CString) -> IoResult<~[Path]> {
+pub fn readdir(p: &CString) -> IoResult<Vec<Path>> {
use rt::global_heap::malloc_raw;
- fn prune(root: &CString, dirs: ~[Path]) -> ~[Path] {
+ fn prune(root: &CString, dirs: Vec<Path>) -> Vec<Path> {
let root = unsafe { CString::new(root.with_ref(|p| p), false) };
let root = Path::new(root);
let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint);
let find_handle = libc::FindFirstFileW(path_ptr, wfd_ptr as libc::HANDLE);
if find_handle as libc::c_int != libc::INVALID_HANDLE_VALUE {
- let mut paths = ~[];
+ let mut paths = vec!();
let mut more_files = 1 as libc::c_int;
while more_files != 0 {
let fp_buf = rust_list_dir_wfd_fp_buf(wfd_ptr as *c_void);
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<~[Path]> {
+ fn fs_readdir(&mut self, path: &CString, _flags: c_int) -> IoResult<Vec<Path>> {
file::readdir(path)
}
fn fs_lstat(&mut self, path: &CString) -> IoResult<io::FileStat> {
}
pub fn readdir(loop_: &Loop, path: &CString, flags: c_int)
- -> Result<~[Path], UvError>
+ -> Result<Vec<Path>, UvError>
{
execute(|req, cb| unsafe {
uvll::uv_fs_readdir(loop_.handle,
req, path.with_ref(|p| p), flags, cb)
}).map(|req| unsafe {
- let mut paths = ~[];
+ let mut paths = vec!();
let path = CString::new(path.with_ref(|p| p), false);
let parent = Path::new(path);
let _ = c_str::from_c_multistring(req.get_ptr() as *libc::c_char,
r.map_err(uv_error_to_io_error)
}
fn fs_readdir(&mut self, path: &CString, flags: c_int)
- -> Result<~[Path], IoError>
+ -> Result<Vec<Path>, IoError>
{
let r = FsRequest::readdir(&self.loop_, path, flags);
r.map_err(uv_error_to_io_error)
/// Will return an error if the provided `from` doesn't exist, the process lacks
/// permissions to view the contents or if the `path` points at a non-directory
/// file
-pub fn readdir(path: &Path) -> IoResult<~[Path]> {
+pub fn readdir(path: &Path) -> IoResult<Vec<Path>> {
LocalIo::maybe_raise(|io| {
io.fs_readdir(&path.to_c_str(), 0)
})
/// An iterator which walks over a directory
pub struct Directories {
- stack: ~[Path],
+ stack: Vec<Path>,
}
impl Iterator<Path> for Directories {
use result::Err;
use rt::local::Local;
use rt::task::Task;
+use vec::Vec;
use ai = io::net::addrinfo;
use io;
fn fs_rmdir(&mut self, path: &CString) -> IoResult<()>;
fn fs_rename(&mut self, path: &CString, to: &CString) -> IoResult<()>;
fn fs_readdir(&mut self, path: &CString, flags: c_int) ->
- IoResult<~[Path]>;
+ IoResult<Vec<Path>>;
fn fs_lstat(&mut self, path: &CString) -> IoResult<FileStat>;
fn fs_chown(&mut self, path: &CString, uid: int, gid: int) ->
IoResult<()>;