Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -51,10 +51,17 @@ * \param path The path to check * \return A boolean whether there is a directory at the specified path */ + (BOOL)directoryExistsAtPath: (OFString*)path; +/** + * Creates a directory at the specified path. + * + * \param path The path of the directory + */ ++ (void)createDirectoryAtPath: (OFString*)path; + /** * \param path The path of the directory * \return An array of OFStrings with the files at the specified path */ + (OFArray*)filesInDirectoryAtPath: (OFString*)path; Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -40,10 +40,11 @@ #ifndef S_IROTH # define S_IROTH 0 #endif #define DEFAULT_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH +#define DIR_MODE DEFAULT_MODE | S_IXUSR | S_IXGRP | S_IXOTH OFFile *of_stdin = nil; OFFile *of_stdout = nil; OFFile *of_stderr = nil; @@ -128,10 +129,17 @@ if (S_ISDIR(s.st_mode)) return YES; return NO; } + ++ (void)createDirectoryAtPath: (OFString*)path +{ + if (mkdir([path cString], DIR_MODE)) + @throw [OFCreateDirectoryFailedException newWithClass: self + path: path]; +} + (OFArray*)filesInDirectoryAtPath: (OFString*)path { OFAutoreleasePool *pool; OFMutableArray *files;