diff options
| author | bors <bors@rust-lang.org> | 2013-09-17 14:05:45 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-09-17 14:05:45 -0700 |
| commit | c135cb268355afe77d2ce0313a8d3e20a4e2fdd3 (patch) | |
| tree | 561787933db67139783cc13d1d2ac276391120f3 /src/rt | |
| parent | 9e8fb4ad61cfe97413eb92d764aa6aeeb23d5afa (diff) | |
| parent | 70152ff55722878cde684ee6462c14c65f2c4729 (diff) | |
| download | rust-c135cb268355afe77d2ce0313a8d3e20a4e2fdd3.tar.gz rust-c135cb268355afe77d2ce0313a8d3e20a4e2fdd3.zip | |
auto merge of #9235 : olsonjeffery/rust/newrt_file_io_1, r=thestinger
A quick rundown:
- added `file::{readdir, stat, mkdir, rmdir}`
- Added access-constrained versions of `FileStream`; `FileReader` and `FileWriter` respectively
- big rework in `uv::file` .. most actions are by-val-self methods on `FsRequest`; `FileDescriptor` has gone the way of the dinosaurs
- playing nice w/ homing IO (I just copied ecr's work, hehe), etc
- added `FileInfo` trait, with an impl for `Path`
- wrapper for file-specific actions, with the file path always implied by self's value
- has the means to create `FileReader` & `FileWriter` (this isn't exposed in the top-level free function API)
- has "safe" wrappers for `stat()` that won't throw in the event of non-existence/error (in this case, I mean `is_file` and `exists`)
- actions should fail if done on non-regular-files, as appropriate
- added `DirectoryInfo` trait, with an impl for `Path`
- pretty much ditto above, but for directories
- added `readdir` (!!) to iterate over entries in a dir as a `~[Path]` (this was *brutal* to get working)
...<del>and lots of other stuff</del>not really. Do your worst!
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/rust_uv.cpp | 51 | ||||
| -rw-r--r-- | src/rt/rustrt.def.in | 7 |
2 files changed, 58 insertions, 0 deletions
diff --git a/src/rt/rust_uv.cpp b/src/rt/rust_uv.cpp index bfdf0e67a9b..9b460cffd74 100644 --- a/src/rt/rust_uv.cpp +++ b/src/rt/rust_uv.cpp @@ -542,6 +542,10 @@ extern "C" int rust_uv_get_result_from_fs_req(uv_fs_t* req) { return req->result; } +extern "C" void* +rust_uv_get_ptr_from_fs_req(uv_fs_t* req) { + return req->ptr; +} extern "C" uv_loop_t* rust_uv_get_loop_from_fs_req(uv_fs_t* req) { return req->loop; @@ -551,3 +555,50 @@ extern "C" uv_loop_t* rust_uv_get_loop_from_getaddrinfo_req(uv_getaddrinfo_t* req) { return req->loop; } + +extern "C" int +rust_uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { + return uv_fs_stat(loop, req, path, cb); +} +extern "C" int +rust_uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { + return uv_fs_fstat(loop, req, file, cb); +} + +extern "C" void +rust_uv_populate_uv_stat(uv_fs_t* req_in, uv_stat_t* stat_out) { + stat_out->st_dev = req_in->statbuf.st_dev; + stat_out->st_mode = req_in->statbuf.st_mode; + stat_out->st_nlink = req_in->statbuf.st_nlink; + stat_out->st_uid = req_in->statbuf.st_uid; + stat_out->st_gid = req_in->statbuf.st_gid; + stat_out->st_rdev = req_in->statbuf.st_rdev; + stat_out->st_ino = req_in->statbuf.st_ino; + stat_out->st_size = req_in->statbuf.st_size; + stat_out->st_blksize = req_in->statbuf.st_blksize; + stat_out->st_blocks = req_in->statbuf.st_blocks; + stat_out->st_flags = req_in->statbuf.st_flags; + stat_out->st_gen = req_in->statbuf.st_gen; + stat_out->st_atim.tv_sec = req_in->statbuf.st_atim.tv_sec; + stat_out->st_atim.tv_nsec = req_in->statbuf.st_atim.tv_nsec; + stat_out->st_mtim.tv_sec = req_in->statbuf.st_mtim.tv_sec; + stat_out->st_mtim.tv_nsec = req_in->statbuf.st_mtim.tv_nsec; + stat_out->st_ctim.tv_sec = req_in->statbuf.st_ctim.tv_sec; + stat_out->st_ctim.tv_nsec = req_in->statbuf.st_ctim.tv_nsec; + stat_out->st_birthtim.tv_sec = req_in->statbuf.st_birthtim.tv_sec; + stat_out->st_birthtim.tv_nsec = req_in->statbuf.st_birthtim.tv_nsec; +} + +extern "C" int +rust_uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb) { + return uv_fs_mkdir(loop, req, path, mode, cb); +} +extern "C" int +rust_uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { + return uv_fs_rmdir(loop, req, path, cb); +} + +extern "C" int +rust_uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, uv_fs_cb cb) { + return uv_fs_readdir(loop, req, path, flags, cb); +} diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 4cbee0dcbd0..3be958837dc 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -113,8 +113,15 @@ rust_uv_fs_write rust_uv_fs_read rust_uv_fs_close rust_uv_get_result_from_fs_req +rust_uv_get_ptr_from_fs_req rust_uv_get_loop_from_fs_req +rust_uv_fs_stat +rust_uv_fs_fstat rust_uv_fs_req_cleanup +rust_uv_populate_uv_stat +rust_uv_fs_mkdir +rust_uv_fs_rmdir +rust_uv_fs_readdir rust_dbg_lock_create rust_dbg_lock_destroy rust_dbg_lock_lock |
