@@ -37,7 +37,7 @@ impl FsRequest {
37
37
fs_req
38
38
}
39
39
40
- fn open_common < P : PathLike > ( loop_ : Loop , path : & P , flags : int , mode : int ,
40
+ fn open_common < P : PathLike > ( loop_ : & Loop , path : & P , flags : int , mode : int ,
41
41
cb : Option < FsCallback > ) -> int {
42
42
let complete_cb_ptr = match cb {
43
43
Some ( _) => compl_cb as * u8 ,
@@ -54,17 +54,17 @@ impl FsRequest {
54
54
if is_sync { req. cleanup_and_delete ( ) ; }
55
55
result
56
56
}
57
- pub fn open < P : PathLike > ( loop_ : Loop , path : & P , flags : int , mode : int ,
57
+ pub fn open < P : PathLike > ( loop_ : & Loop , path : & P , flags : int , mode : int ,
58
58
cb : FsCallback ) {
59
59
FsRequest :: open_common ( loop_, path, flags, mode, Some ( cb) ) ;
60
60
}
61
61
62
- pub fn open_sync < P : PathLike > ( loop_ : Loop , path : & P , flags : int , mode : int ) -> Result < int , UvError > {
62
+ pub fn open_sync < P : PathLike > ( loop_ : & Loop , path : & P , flags : int , mode : int ) -> Result < int , UvError > {
63
63
let result = FsRequest :: open_common ( loop_, path, flags, mode, None ) ;
64
- sync_cleanup ( & loop_, result)
64
+ sync_cleanup ( loop_, result)
65
65
}
66
66
67
- fn unlink_common < P : PathLike > ( loop_ : Loop , path : & P , cb : Option < FsCallback > ) -> int {
67
+ fn unlink_common < P : PathLike > ( loop_ : & Loop , path : & P , cb : Option < FsCallback > ) -> int {
68
68
let complete_cb_ptr = match cb {
69
69
Some ( _) => compl_cb as * u8 ,
70
70
None => 0 as * u8
@@ -80,13 +80,13 @@ impl FsRequest {
80
80
if is_sync { req. cleanup_and_delete ( ) ; }
81
81
result
82
82
}
83
- pub fn unlink < P : PathLike > ( loop_ : Loop , path : & P , cb : FsCallback ) {
83
+ pub fn unlink < P : PathLike > ( loop_ : & Loop , path : & P , cb : FsCallback ) {
84
84
let result = FsRequest :: unlink_common ( loop_, path, Some ( cb) ) ;
85
- sync_cleanup ( & loop_, result) ;
85
+ sync_cleanup ( loop_, result) ;
86
86
}
87
- pub fn unlink_sync < P : PathLike > ( loop_ : Loop , path : & P ) -> Result < int , UvError > {
87
+ pub fn unlink_sync < P : PathLike > ( loop_ : & Loop , path : & P ) -> Result < int , UvError > {
88
88
let result = FsRequest :: unlink_common ( loop_, path, None ) ;
89
- sync_cleanup ( & loop_, result)
89
+ sync_cleanup ( loop_, result)
90
90
}
91
91
92
92
pub fn install_req_data ( & self , cb : Option < FsCallback > ) {
@@ -158,7 +158,7 @@ impl FileDescriptor {
158
158
}
159
159
160
160
// as per bnoordhuis in #libuv: offset >= 0 uses prwrite instead of write
161
- fn write_common ( & mut self , loop_ : Loop , buf : Buf , offset : i64 , cb : Option < FsCallback > )
161
+ fn write_common ( & mut self , loop_ : & Loop , buf : Buf , offset : i64 , cb : Option < FsCallback > )
162
162
-> int {
163
163
let complete_cb_ptr = match cb {
164
164
Some ( _) => compl_cb as * u8 ,
@@ -177,16 +177,16 @@ impl FileDescriptor {
177
177
if is_sync { req. cleanup_and_delete ( ) ; }
178
178
result
179
179
}
180
- pub fn write ( & mut self , loop_ : Loop , buf : Buf , offset : i64 , cb : FsCallback ) {
180
+ pub fn write ( & mut self , loop_ : & Loop , buf : Buf , offset : i64 , cb : FsCallback ) {
181
181
self . write_common ( loop_, buf, offset, Some ( cb) ) ;
182
182
}
183
- pub fn write_sync ( & mut self , loop_ : Loop , buf : Buf , offset : i64 )
183
+ pub fn write_sync ( & mut self , loop_ : & Loop , buf : Buf , offset : i64 )
184
184
-> Result < int , UvError > {
185
185
let result = self . write_common ( loop_, buf, offset, None ) ;
186
- sync_cleanup ( & loop_, result)
186
+ sync_cleanup ( loop_, result)
187
187
}
188
188
189
- fn read_common ( & mut self , loop_ : Loop , buf : Buf ,
189
+ fn read_common ( & mut self , loop_ : & Loop , buf : Buf ,
190
190
offset : i64 , cb : Option < FsCallback > )
191
191
-> int {
192
192
let complete_cb_ptr = match cb {
@@ -205,16 +205,16 @@ impl FileDescriptor {
205
205
if is_sync { req. cleanup_and_delete ( ) ; }
206
206
result
207
207
}
208
- pub fn read ( & mut self , loop_ : Loop , buf : Buf , offset : i64 , cb : FsCallback ) {
208
+ pub fn read ( & mut self , loop_ : & Loop , buf : Buf , offset : i64 , cb : FsCallback ) {
209
209
self . read_common ( loop_, buf, offset, Some ( cb) ) ;
210
210
}
211
- pub fn read_sync ( & mut self , loop_ : Loop , buf : Buf , offset : i64 )
211
+ pub fn read_sync ( & mut self , loop_ : & Loop , buf : Buf , offset : i64 )
212
212
-> Result < int , UvError > {
213
213
let result = self . read_common ( loop_, buf, offset, None ) ;
214
- sync_cleanup ( & loop_, result)
214
+ sync_cleanup ( loop_, result)
215
215
}
216
216
217
- fn close_common ( self , loop_ : Loop , cb : Option < FsCallback > ) -> int {
217
+ fn close_common ( self , loop_ : & Loop , cb : Option < FsCallback > ) -> int {
218
218
let complete_cb_ptr = match cb {
219
219
Some ( _) => compl_cb as * u8 ,
220
220
None => 0 as * u8
@@ -228,12 +228,12 @@ impl FileDescriptor {
228
228
if is_sync { req. cleanup_and_delete ( ) ; }
229
229
result
230
230
}
231
- pub fn close ( self , loop_ : Loop , cb : FsCallback ) {
231
+ pub fn close ( self , loop_ : & Loop , cb : FsCallback ) {
232
232
self . close_common ( loop_, Some ( cb) ) ;
233
233
}
234
- pub fn close_sync ( self , loop_ : Loop ) -> Result < int , UvError > {
234
+ pub fn close_sync ( self , loop_ : & Loop ) -> Result < int , UvError > {
235
235
let result = self . close_common ( loop_, None ) ;
236
- sync_cleanup ( & loop_, result)
236
+ sync_cleanup ( loop_, result)
237
237
}
238
238
}
239
239
extern fn compl_cb ( req : * uv_fs_t ) {
@@ -301,26 +301,25 @@ mod test {
301
301
let read_buf = slice_to_uv_buf ( read_mem) ;
302
302
let read_buf_ptr: * Buf = & read_buf;
303
303
let p = Path ( path_str) ;
304
- do FsRequest :: open ( loop_, & p, create_flags as int , mode as int )
304
+ do FsRequest :: open ( & loop_, & p, create_flags as int , mode as int )
305
305
|req, uverr| {
306
- let loop_ = req. get_loop ( ) ;
307
306
assert ! ( uverr. is_none( ) ) ;
308
307
let mut fd = FileDescriptor :: from_open_req ( req) ;
309
308
let raw_fd = fd. native_handle ( ) ;
310
309
let buf = unsafe { * write_buf_ptr } ;
311
- do fd. write ( loop_ , buf, -1 ) |_ , uverr| {
310
+ do fd. write ( & req . get_loop ( ) , buf, -1 ) |req , uverr| {
312
311
let fd = FileDescriptor ( raw_fd) ;
313
- do fd. close ( loop_ ) |req, _| {
312
+ do fd. close ( & req . get_loop ( ) ) |req, _| {
314
313
let loop_ = req. get_loop ( ) ;
315
314
assert ! ( uverr. is_none( ) ) ;
316
- do FsRequest :: open ( loop_, & Path ( path_str) , read_flags as int , 0 )
315
+ do FsRequest :: open ( & loop_, & Path ( path_str) , read_flags as int , 0 )
317
316
|req, uverr| {
318
317
assert ! ( uverr. is_none( ) ) ;
319
318
let loop_ = req. get_loop ( ) ;
320
319
let mut fd = FileDescriptor :: from_open_req ( req) ;
321
320
let raw_fd = fd. native_handle ( ) ;
322
321
let read_buf = unsafe { * read_buf_ptr } ;
323
- do fd. read ( loop_, read_buf, 0 ) |req, uverr| {
322
+ do fd. read ( & loop_, read_buf, 0 ) |req, uverr| {
324
323
assert ! ( uverr. is_none( ) ) ;
325
324
let loop_ = req. get_loop ( ) ;
326
325
// we know nread >=0 because uverr is none..
@@ -334,8 +333,9 @@ mod test {
334
333
read_buf. base , nread) )
335
334
} ;
336
335
assert ! ( read_str == ~"hello");
337
- do FileDescriptor(raw_fd).close(loop_) |_ ,uverr| {
336
+ do FileDescriptor(raw_fd).close(& loop_) |req ,uverr| {
338
337
assert!(uverr.is_none());
338
+ let loop_ = &req.get_loop();
339
339
do FsRequest::unlink(loop_, &Path(path_str))
340
340
|_,uverr| {
341
341
assert!(uverr.is_none());
@@ -367,26 +367,26 @@ mod test {
367
367
let write_val = " hello".as_bytes().to_owned();
368
368
let write_buf = slice_to_uv_buf(write_val);
369
369
// open/create
370
- let result = FsRequest::open_sync(loop_, &Path(path_str),
370
+ let result = FsRequest::open_sync(& loop_, &Path(path_str),
371
371
create_flags as int, mode as int);
372
372
assert!(result.is_ok());
373
373
let mut fd = FileDescriptor(result.unwrap() as i32);
374
374
// write
375
- let result = fd.write_sync(loop_, write_buf, -1);
375
+ let result = fd.write_sync(& loop_, write_buf, -1);
376
376
assert!(result.is_ok());
377
377
// close
378
- let result = fd.close_sync(loop_);
378
+ let result = fd.close_sync(& loop_);
379
379
assert!(result.is_ok());
380
380
// re-open
381
- let result = FsRequest::open_sync(loop_, &Path(path_str),
381
+ let result = FsRequest::open_sync(& loop_, &Path(path_str),
382
382
read_flags as int,0);
383
383
assert!(result.is_ok());
384
384
let len = 1028;
385
385
let mut fd = FileDescriptor(result.unwrap() as i32);
386
386
// read
387
387
let read_mem: ~[u8] = vec::from_elem(len, 0u8);
388
388
let buf = slice_to_uv_buf(read_mem);
389
- let result = fd.read_sync(loop_, buf, 0);
389
+ let result = fd.read_sync(& loop_, buf, 0);
390
390
assert!(result.is_ok());
391
391
let nread = result.unwrap();
392
392
// nread == 0 would be EOF.. we know it's >= zero because otherwise
@@ -396,10 +396,10 @@ mod test {
396
396
read_mem.slice(0, nread as uint));
397
397
assert!(read_str == ~" hello");
398
398
// close
399
- let result = fd.close_sync(loop_);
399
+ let result = fd.close_sync(& loop_);
400
400
assert!(result.is_ok());
401
401
// unlink
402
- let result = FsRequest::unlink_sync(loop_, &Path(path_str));
402
+ let result = FsRequest::unlink_sync(& loop_, &Path(path_str));
403
403
assert!(result.is_ok());
404
404
} else { fail!(" nread was 0 .. wudn' t expectin' that. "); }
405
405
loop_.close();
@@ -416,7 +416,7 @@ mod test {
416
416
file_test_full_simple_impl_sync();
417
417
}
418
418
419
- fn naive_print(loop_: Loop, input: &str) {
419
+ fn naive_print(loop_: & Loop, input: &str) {
420
420
let mut stdout = FileDescriptor(STDOUT_FILENO);
421
421
let write_val = input.as_bytes();
422
422
let write_buf = slice_to_uv_buf(write_val);
@@ -427,7 +427,7 @@ mod test {
427
427
fn file_test_write_to_stdout() {
428
428
do run_in_bare_thread {
429
429
let mut loop_ = Loop::new();
430
- naive_print(loop_, " zanzibar!\n ") ;
430
+ naive_print(& loop_, " zanzibar!\n ") ;
431
431
loop_. run ( ) ;
432
432
loop_. close ( ) ;
433
433
} ;
0 commit comments