diff options
| author | Brian Anderson <banderson@mozilla.com> | 2013-03-14 19:54:04 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2013-03-18 16:59:37 -0700 |
| commit | 7ef54c7ecd625376de092cbd741621987673c45f (patch) | |
| tree | dd57a33370576e7eae36e0839da21acf8753e11c /src | |
| parent | 57e85b5f947387195cec1338fcb94b7cfb88bd86 (diff) | |
| download | rust-7ef54c7ecd625376de092cbd741621987673c45f.tar.gz rust-7ef54c7ecd625376de092cbd741621987673c45f.zip | |
core: Begin uv file system bindings
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/rt/uv.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/libcore/rt/uv.rs b/src/libcore/rt/uv.rs index cc9e2fe8a7a..aab6d898ea8 100644 --- a/src/libcore/rt/uv.rs +++ b/src/libcore/rt/uv.rs @@ -498,6 +498,42 @@ impl NativeHandle<*uvll::uv_write_t> for WriteRequest { } } +type FsCallback = ~fn(FsRequest, Option<UvError>); +impl Callback for FsCallback { } + +pub struct FsRequest(*uvll::uv_fs_t); + +impl Request for FsRequest; + +impl FsRequest { + static fn new() -> FsRequest { + let fs_req = unsafe { malloc_req(UV_FS) }; + fail_unless!(fs_req.is_not_null()); + let fs_req = fs_req as *uvll::uv_write_t; + uvll::set_data_for_uv_req(fs_req, null::<()>()); + Native(fs_req) + } + + fn delete(self) { + unsafe { free_req(self.native_handle() as *c_void) } + } + + fn open(&mut self, loop_: &EventLoop, cb: FsCallback) { + } + + fn close(&mut self, loop_: &EventLoop, cb: FsCallback) { + } +} + +impl NativeHandle<*uvll::uv_fs_t> for FsRequest { + static fn from_native_handle(handle: *uvll:: uv_fs_t) -> FsRequest { + FsRequest(handle) + } + fn native_handle(&self) -> *uvll::uv_fs_t { + match self { &FsRequest(ptr) => ptr } + } +} + // XXX: Need to define the error constants like EOF so they can be // compared to the UvError type |
