@@ -17,7 +17,7 @@ use rt::rtio::{RtioFileStream, IoFactory, IoFactoryObject};
1717use rt:: io:: { io_error, read_error, EndOfFile ,
1818 FileMode , FileAccess , FileStat , IoError ,
1919 PathAlreadyExists , PathDoesntExist ,
20- MismatchedFileTypeForOperation } ;
20+ MismatchedFileTypeForOperation , ignore_io_error } ;
2121use rt:: local:: Local ;
2222use option:: { Some , None } ;
2323use path:: Path ;
@@ -248,18 +248,6 @@ impl Seek for FileStream {
248248 }
249249}
250250
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-
263251/// Shared functionality between `FileInfo` and `DirectoryInfo`
264252pub trait FileSystemInfo {
265253 /// Get the filesystem path that this instance points at,
@@ -277,7 +265,7 @@ pub trait FileSystemInfo {
277265 /// returns `true` if the location pointed at by the enclosing
278266 /// exists on the filesystem
279267 fn exists ( & self ) -> bool {
280- match suppressed_stat ( || self . stat ( ) ) {
268+ match ignore_io_error ( || self . stat ( ) ) {
281269 Some ( _) => true ,
282270 None => false
283271 }
@@ -306,7 +294,7 @@ pub trait FileInfo : FileSystemInfo {
306294 /// false for paths to non-existent locations or directories or
307295 /// other non-regular files (named pipes, etc).
308296 fn is_file ( & self ) -> bool {
309- match suppressed_stat ( || self . stat ( ) ) {
297+ match ignore_io_error ( || self . stat ( ) ) {
310298 Some ( s) => s. is_file ,
311299 None => false
312300 }
@@ -315,7 +303,7 @@ pub trait FileInfo : FileSystemInfo {
315303 /// Attempts to open a regular file for reading/writing based
316304 /// on provided inputs
317305 fn open_stream ( & self , mode : FileMode , access : FileAccess ) -> Option < FileStream > {
318- match suppressed_stat ( || self . stat ( ) ) {
306+ match ignore_io_error ( || self . stat ( ) ) {
319307 Some ( s) => match s. is_file {
320308 true => open ( self . get_path ( ) , mode, access) ,
321309 false => None
@@ -364,7 +352,7 @@ trait DirectoryInfo : FileSystemInfo {
364352 /// false for paths to non-existent locations or if the item is
365353 /// not a directory (eg files, named pipes, links, etc)
366354 fn is_dir ( & self ) -> bool {
367- match suppressed_stat ( || self . stat ( ) ) {
355+ match ignore_io_error ( || self . stat ( ) ) {
368356 Some ( s) => s. is_dir ,
369357 None => false
370358 }
@@ -375,7 +363,7 @@ trait DirectoryInfo : FileSystemInfo {
375363 /// at that location or if some other error occurs during
376364 /// the mkdir operation
377365 fn mkdir ( & self ) {
378- match suppressed_stat ( || self . stat ( ) ) {
366+ match ignore_io_error ( || self . stat ( ) ) {
379367 Some ( _) => {
380368 io_error:: cond. raise ( IoError {
381369 kind : PathAlreadyExists ,
@@ -391,7 +379,7 @@ trait DirectoryInfo : FileSystemInfo {
391379 /// the type underlying the given `DirectoryInfo`. Will fail
392380 /// if there is no directory at the given location or if
393381 fn rmdir ( & self ) {
394- match suppressed_stat ( || self . stat ( ) ) {
382+ match ignore_io_error ( || self . stat ( ) ) {
395383 Some ( s) => {
396384 match s. is_dir {
397385 true => rmdir ( self . get_path ( ) ) ,
0 commit comments