Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -38,10 +38,15 @@ * It is not closed when the OFFile object is deallocated! * \return A new autoreleased OFFile */ + fileWithFileDescriptor: (int)fd; +/** + * \return A boolean whether there is a file at the specified path + */ ++ (BOOL)fileExistsAtPath: (OFString*)path; + /** * Changes the mode of a file. * * Only changes read-only flag on Windows. * Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -99,10 +99,23 @@ + fileWithFileDescriptor: (int)fd_ { return [[[self alloc] initWithFileDescriptor: fd_] autorelease]; } + ++ (BOOL)fileExistsAtPath: (OFString*)path +{ + struct stat s; + + if (stat([path cString], &s) == -1) + return NO; + + if (S_ISREG(s.st_mode)) + return YES; + + return NO; +} + (void)changeModeOfFile: (OFString*)path toMode: (mode_t)mode { #ifndef _WIN32