Skip to content

Commit 11fee07

Browse files
committed
---
yaml --- r: 89625 b: refs/heads/master c: 7bf58c2 h: refs/heads/master i: 89623: e249276 v: v3
1 parent baa424e commit 11fee07

File tree

6 files changed

+42
-5
lines changed

6 files changed

+42
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: d7b6502784cad759cee9961426313017f052d5ba
2+
refs/heads/master: 7bf58c2baaac3f7cb3c8e8d735b27ac9e7d3cd78
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8

trunk/src/librustuv/file.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,21 @@ impl FsRequest {
206206
assert_eq!(ret, 0);
207207
}
208208

209+
pub fn rename(self, loop_: &Loop, path: &CString, to: &CString, cb: FsCallback) {
210+
let complete_cb_ptr = {
211+
let mut me = self;
212+
me.req_boilerplate(Some(cb))
213+
};
214+
let ret = unsafe {
215+
uvll::fs_rename(loop_.native_handle(),
216+
self.native_handle(),
217+
path.with_ref(|p| p),
218+
to.with_ref(|p| p),
219+
complete_cb_ptr)
220+
};
221+
assert_eq!(ret, 0);
222+
}
223+
209224
pub fn readdir(self, loop_: &Loop, path: &CString,
210225
flags: c_int, cb: FsCallback) {
211226
let complete_cb_ptr = {

trunk/src/librustuv/uvio.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,9 @@ impl IoFactory for UvIoFactory {
699699
assert!(!result_cell.is_empty());
700700
return result_cell.take();
701701
}
702-
fn fs_mkdir(&mut self, path: &CString) -> Result<(), IoError> {
703-
let mode = S_IRWXU as int;
702+
fn fs_mkdir(&mut self, path: &CString, mode: int) -> Result<(), IoError> {
704703
do uv_fs_helper(self.uv_loop(), path) |mkdir_req, l, p, cb| {
705-
do mkdir_req.mkdir(l, p, mode as int) |req, err| {
704+
do mkdir_req.mkdir(l, p, mode) |req, err| {
706705
cb(req, err)
707706
};
708707
}
@@ -714,6 +713,15 @@ impl IoFactory for UvIoFactory {
714713
};
715714
}
716715
}
716+
fn fs_rename(&mut self, path: &CString, to: &CString) -> Result<(), IoError> {
717+
let to = to.with_ref(|p| p);
718+
do uv_fs_helper(self.uv_loop(), path) |rename_req, l, p, cb| {
719+
let to = unsafe { CString::new(to, false) };
720+
do rename_req.rename(l, p, &to) |req, err| {
721+
cb(req, err)
722+
};
723+
}
724+
}
717725
fn fs_readdir(&mut self, path: &CString, flags: c_int) ->
718726
Result<~[Path], IoError> {
719727
use str::StrSlice;

trunk/src/librustuv/uvll.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,12 @@ pub unsafe fn fs_rmdir(loop_ptr: *uv_loop_t, req: *uv_fs_t, path: *c_char,
807807

808808
rust_uv_fs_rmdir(loop_ptr, req, path, cb)
809809
}
810+
pub unsafe fn fs_rename(loop_ptr: *uv_loop_t, req: *uv_fs_t, path: *c_char,
811+
to: *c_char, cb: *u8) -> c_int {
812+
#[fixed_stack_segment]; #[inline(never)];
813+
814+
rust_uv_fs_rename(loop_ptr, req, path, to, cb)
815+
}
810816
pub unsafe fn fs_readdir(loop_ptr: *uv_loop_t, req: *uv_fs_t, path: *c_char,
811817
flags: c_int, cb: *u8) -> c_int {
812818
#[fixed_stack_segment]; #[inline(never)];
@@ -1107,6 +1113,8 @@ extern {
11071113
mode: c_int, cb: *u8) -> c_int;
11081114
fn rust_uv_fs_rmdir(loop_ptr: *c_void, req: *uv_fs_t, path: *c_char,
11091115
cb: *u8) -> c_int;
1116+
fn rust_uv_fs_rename(loop_ptr: *c_void, req: *uv_fs_t, path: *c_char,
1117+
to: *c_char, cb: *u8) -> c_int;
11101118
fn rust_uv_fs_readdir(loop_ptr: *c_void, req: *uv_fs_t, path: *c_char,
11111119
flags: c_int, cb: *u8) -> c_int;
11121120
fn rust_uv_fs_req_cleanup(req: *uv_fs_t);

trunk/src/libstd/rt/rtio.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ pub trait IoFactory {
102102
-> Result<~RtioFileStream, IoError>;
103103
fn fs_unlink(&mut self, path: &CString) -> Result<(), IoError>;
104104
fn fs_stat(&mut self, path: &CString) -> Result<FileStat, IoError>;
105-
fn fs_mkdir(&mut self, path: &CString) -> Result<(), IoError>;
105+
fn fs_mkdir(&mut self, path: &CString, mode: int) -> Result<(), IoError>;
106106
fn fs_rmdir(&mut self, path: &CString) -> Result<(), IoError>;
107+
fn fs_rename(&mut self, path: &CString, to: &CString) -> Result<(), IoError>;
107108
fn fs_readdir(&mut self, path: &CString, flags: c_int) ->
108109
Result<~[Path], IoError>;
109110
fn spawn(&mut self, config: ProcessConfig)

trunk/src/rt/rust_uv.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,11 @@ extern "C" int
592592
rust_uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, uv_fs_cb cb) {
593593
return uv_fs_readdir(loop, req, path, flags, cb);
594594
}
595+
extern "C" int
596+
rust_uv_fs_rename(uv_loop_t *loop, uv_fs_t* req, const char *path,
597+
const char *to, uv_fs_cb cb) {
598+
return uv_fs_rename(loop, req, path, to, cb);
599+
}
595600

596601
extern "C" int
597602
rust_uv_spawn(uv_loop_t *loop, uv_process_t *p, uv_process_options_t options) {

0 commit comments

Comments
 (0)