Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -108,10 +108,17 @@ * * \param path The new directory to change to */ + (void)changeToDirectory: (OFString*)path; +/** + * \brief Returns the size of the specified file. + * + * \return The size of the specified file + */ ++ (off_t)sizeOfFile: (OFString*)path; + /** * \brief Returns the date of the last modification of the file. * * \return The date of the last modification of the file */ Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -370,10 +370,24 @@ path: path mode: mode]; # endif } #endif + ++ (off_t)sizeOfFile: (OFString*)path +{ + struct stat s; + + if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], + &s) == -1) + /* FIXME: Maybe use another exception? */ + @throw [OFOpenFileFailedException exceptionWithClass: self + path: path + mode: @"r"]; + + return s.st_size; +} + (OFDate*)modificationDateOfFile: (OFString*)path { struct stat s;