@@ -17,7 +17,7 @@ use rt::rtio::{RtioFileStream, IoFactory, IoFactoryObject};
17
17
use rt:: io:: { io_error, read_error, EndOfFile ,
18
18
FileMode , FileAccess , FileStat , IoError ,
19
19
PathAlreadyExists , PathDoesntExist ,
20
- MismatchedFileTypeForOperation } ;
20
+ MismatchedFileTypeForOperation , ignore_io_error } ;
21
21
use rt:: local:: Local ;
22
22
use option:: { Some , None } ;
23
23
use path:: Path ;
@@ -248,18 +248,6 @@ impl Seek for FileStream {
248
248
}
249
249
}
250
250
251
- // helper for grabbing a stat and ignoring any
252
- // error.. used in Info wrappers
253
- fn suppressed_stat ( cb : & fn ( ) -> Option < FileStat > ) -> Option < FileStat > {
254
- do io_error:: cond. trap ( |_| {
255
- // just swallow the error.. downstream users
256
- // who can make a decision based on a None result
257
- // won't care
258
- } ) . inside {
259
- cb ( )
260
- }
261
- }
262
-
263
251
/// Shared functionality between `FileInfo` and `DirectoryInfo`
264
252
pub trait FileSystemInfo {
265
253
/// Get the filesystem path that this instance points at,
@@ -277,7 +265,7 @@ pub trait FileSystemInfo {
277
265
/// returns `true` if the location pointed at by the enclosing
278
266
/// exists on the filesystem
279
267
fn exists ( & self ) -> bool {
280
- match suppressed_stat ( || self . stat ( ) ) {
268
+ match ignore_io_error ( || self . stat ( ) ) {
281
269
Some ( _) => true ,
282
270
None => false
283
271
}
@@ -306,7 +294,7 @@ pub trait FileInfo : FileSystemInfo {
306
294
/// false for paths to non-existent locations or directories or
307
295
/// other non-regular files (named pipes, etc).
308
296
fn is_file ( & self ) -> bool {
309
- match suppressed_stat ( || self . stat ( ) ) {
297
+ match ignore_io_error ( || self . stat ( ) ) {
310
298
Some ( s) => s. is_file ,
311
299
None => false
312
300
}
@@ -315,7 +303,7 @@ pub trait FileInfo : FileSystemInfo {
315
303
/// Attempts to open a regular file for reading/writing based
316
304
/// on provided inputs
317
305
fn open_stream ( & self , mode : FileMode , access : FileAccess ) -> Option < FileStream > {
318
- match suppressed_stat ( || self . stat ( ) ) {
306
+ match ignore_io_error ( || self . stat ( ) ) {
319
307
Some ( s) => match s. is_file {
320
308
true => open ( self . get_path ( ) , mode, access) ,
321
309
false => None
@@ -364,7 +352,7 @@ trait DirectoryInfo : FileSystemInfo {
364
352
/// false for paths to non-existent locations or if the item is
365
353
/// not a directory (eg files, named pipes, links, etc)
366
354
fn is_dir ( & self ) -> bool {
367
- match suppressed_stat ( || self . stat ( ) ) {
355
+ match ignore_io_error ( || self . stat ( ) ) {
368
356
Some ( s) => s. is_dir ,
369
357
None => false
370
358
}
@@ -375,7 +363,7 @@ trait DirectoryInfo : FileSystemInfo {
375
363
/// at that location or if some other error occurs during
376
364
/// the mkdir operation
377
365
fn mkdir ( & self ) {
378
- match suppressed_stat ( || self . stat ( ) ) {
366
+ match ignore_io_error ( || self . stat ( ) ) {
379
367
Some ( _) => {
380
368
io_error:: cond. raise ( IoError {
381
369
kind : PathAlreadyExists ,
@@ -391,7 +379,7 @@ trait DirectoryInfo : FileSystemInfo {
391
379
/// the type underlying the given `DirectoryInfo`. Will fail
392
380
/// if there is no directory at the given location or if
393
381
fn rmdir ( & self ) {
394
- match suppressed_stat ( || self . stat ( ) ) {
382
+ match ignore_io_error ( || self . stat ( ) ) {
395
383
Some ( s) => {
396
384
match s. is_dir {
397
385
true => rmdir ( self . get_path ( ) ) ,
0 commit comments