@@ -339,15 +339,15 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
339339 libc:: S_IRUSR | libc:: S_IWUSR ) ,
340340 } ;
341341
342- match retry ( || unsafe { libc:: open ( path. with_ref ( |p| p ) , flags, mode) } ) {
342+ match retry ( || unsafe { libc:: open ( path. as_ptr ( ) , flags, mode) } ) {
343343 -1 => Err ( super :: last_error ( ) ) ,
344344 fd => Ok ( FileDesc :: new ( fd, true ) ) ,
345345 }
346346}
347347
348348pub fn mkdir ( p : & CString , mode : uint ) -> IoResult < ( ) > {
349349 super :: mkerr_libc ( retry ( || unsafe {
350- libc:: mkdir ( p. with_ref ( |p| p ) , mode as libc:: mode_t )
350+ libc:: mkdir ( p. as_ptr ( ) , mode as libc:: mode_t )
351351 } ) )
352352}
353353
@@ -356,7 +356,7 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
356356 use libc:: { opendir, readdir_r, closedir} ;
357357
358358 fn prune ( root : & CString , dirs : Vec < Path > ) -> Vec < CString > {
359- let root = unsafe { CString :: new ( root. with_ref ( |p| p ) , false ) } ;
359+ let root = unsafe { CString :: new ( root. as_ptr ( ) , false ) } ;
360360 let root = Path :: new ( root) ;
361361
362362 dirs. move_iter ( ) . filter ( |path| {
@@ -373,7 +373,7 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
373373 let mut buf = Vec :: < u8 > :: with_capacity ( size as uint ) ;
374374 let ptr = buf. as_mut_slice ( ) . as_mut_ptr ( ) as * mut dirent_t ;
375375
376- let dir_ptr = p . with_ref ( |buf| unsafe { opendir ( buf ) } ) ;
376+ let dir_ptr = unsafe { opendir ( p . as_ptr ( ) ) } ;
377377
378378 if dir_ptr as uint != 0 {
379379 let mut paths = vec ! ( ) ;
@@ -393,36 +393,36 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
393393}
394394
395395pub fn unlink ( p : & CString ) -> IoResult < ( ) > {
396- super :: mkerr_libc ( retry ( || unsafe { libc:: unlink ( p. with_ref ( |p| p ) ) } ) )
396+ super :: mkerr_libc ( retry ( || unsafe { libc:: unlink ( p. as_ptr ( ) ) } ) )
397397}
398398
399399pub fn rename ( old : & CString , new : & CString ) -> IoResult < ( ) > {
400400 super :: mkerr_libc ( retry ( || unsafe {
401- libc:: rename ( old. with_ref ( |p| p ) , new. with_ref ( |p| p ) )
401+ libc:: rename ( old. as_ptr ( ) , new. as_ptr ( ) )
402402 } ) )
403403}
404404
405405pub fn chmod ( p : & CString , mode : uint ) -> IoResult < ( ) > {
406406 super :: mkerr_libc ( retry ( || unsafe {
407- libc:: chmod ( p. with_ref ( |p| p ) , mode as libc:: mode_t )
407+ libc:: chmod ( p. as_ptr ( ) , mode as libc:: mode_t )
408408 } ) )
409409}
410410
411411pub fn rmdir ( p : & CString ) -> IoResult < ( ) > {
412412 super :: mkerr_libc ( retry ( || unsafe {
413- libc:: rmdir ( p. with_ref ( |p| p ) )
413+ libc:: rmdir ( p. as_ptr ( ) )
414414 } ) )
415415}
416416
417417pub fn chown ( p : & CString , uid : int , gid : int ) -> IoResult < ( ) > {
418418 super :: mkerr_libc ( retry ( || unsafe {
419- libc:: chown ( p. with_ref ( |p| p ) , uid as libc:: uid_t ,
419+ libc:: chown ( p. as_ptr ( ) , uid as libc:: uid_t ,
420420 gid as libc:: gid_t )
421421 } ) )
422422}
423423
424424pub fn readlink ( p : & CString ) -> IoResult < CString > {
425- let p = p. with_ref ( |p| p ) ;
425+ let p = p. as_ptr ( ) ;
426426 let mut len = unsafe { libc:: pathconf ( p as * mut _ , libc:: _PC_NAME_MAX) } ;
427427 if len == -1 {
428428 len = 1024 ; // FIXME: read PATH_MAX from C ffi?
@@ -443,13 +443,13 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
443443
444444pub fn symlink ( src : & CString , dst : & CString ) -> IoResult < ( ) > {
445445 super :: mkerr_libc ( retry ( || unsafe {
446- libc:: symlink ( src. with_ref ( |p| p ) , dst. with_ref ( |p| p ) )
446+ libc:: symlink ( src. as_ptr ( ) , dst. as_ptr ( ) )
447447 } ) )
448448}
449449
450450pub fn link ( src : & CString , dst : & CString ) -> IoResult < ( ) > {
451451 super :: mkerr_libc ( retry ( || unsafe {
452- libc:: link ( src. with_ref ( |p| p ) , dst. with_ref ( |p| p ) )
452+ libc:: link ( src. as_ptr ( ) , dst. as_ptr ( ) )
453453 } ) )
454454}
455455
@@ -489,15 +489,15 @@ fn mkstat(stat: &libc::stat) -> rtio::FileStat {
489489
490490pub fn stat ( p : & CString ) -> IoResult < rtio:: FileStat > {
491491 let mut stat: libc:: stat = unsafe { mem:: zeroed ( ) } ;
492- match retry ( || unsafe { libc:: stat ( p. with_ref ( |p| p ) , & mut stat) } ) {
492+ match retry ( || unsafe { libc:: stat ( p. as_ptr ( ) , & mut stat) } ) {
493493 0 => Ok ( mkstat ( & stat) ) ,
494494 _ => Err ( super :: last_error ( ) ) ,
495495 }
496496}
497497
498498pub fn lstat ( p : & CString ) -> IoResult < rtio:: FileStat > {
499499 let mut stat: libc:: stat = unsafe { mem:: zeroed ( ) } ;
500- match retry ( || unsafe { libc:: lstat ( p. with_ref ( |p| p ) , & mut stat) } ) {
500+ match retry ( || unsafe { libc:: lstat ( p. as_ptr ( ) , & mut stat) } ) {
501501 0 => Ok ( mkstat ( & stat) ) ,
502502 _ => Err ( super :: last_error ( ) ) ,
503503 }
@@ -509,7 +509,7 @@ pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
509509 modtime : ( mtime / 1000 ) as libc:: time_t ,
510510 } ;
511511 super :: mkerr_libc ( retry ( || unsafe {
512- libc:: utime ( p. with_ref ( |p| p ) , & buf)
512+ libc:: utime ( p. as_ptr ( ) , & buf)
513513 } ) )
514514}
515515
0 commit comments