Index: src/OFExceptions.h ================================================================== --- src/OFExceptions.h +++ src/OFExceptions.h @@ -244,17 +244,17 @@ */ @interface OFOpenFileFailedException: OFException { OFString *path; OFString *mode; - int err; + int err; } /** * \param class_ The class of the object which caused the exception - * \param path A string of the path to the file tried to open - * \param mode A string of the mode in which the file should have been opened + * \param path A string with the path of the file tried to open + * \param mode A string with the mode in which the file should have been opened * \return A new open file failed exception */ + newWithClass: (Class)class_ path: (OFString*)path mode: (OFString*)mode; @@ -261,12 +261,12 @@ /** * Initializes an already allocated open file failed exception. * * \param class_ The class of the object which caused the exception - * \param path A string of the path to the file which couldn't be opened - * \param mode A string of the mode in which the file should have been opened + * \param path A string with the path of the file which couldn't be opened + * \param mode A string with the mode in which the file should have been opened * \return An initialized open file failed exception */ - initWithClass: (Class)class_ path: (OFString*)path mode: (OFString*)mode; @@ -275,16 +275,16 @@ * \return The errno from when the exception was created */ - (int)errNo; /** - * \return A string of the path to the file which couldn't be opened + * \return A string with the path of the file which couldn't be opened */ - (OFString*)path; /** - * \return A string of the mode in which the file should have been opened + * \return A string with the mode in which the file should have been opened */ - (OFString*)mode; @end /** @@ -349,10 +349,48 @@ * \return The errno from when the exception was created */ - (int)errNo; @end +/** + * \brief An exception indicating a directory couldn't be created. + */ +@interface OFCreateDirectoryFailedException: OFException +{ + OFString *path; + int err; +} + +/** + * \param class_ The class of the object which caused the exception + * \param path A string with the path of the directory which couldn't be created + * \return A new create directory failed exception + */ ++ newWithClass: (Class)class_ + path: (OFString*)path; + +/** + * Initializes an already allocated create directory failed exception. + * + * \param class_ The class of the object which caused the exception + * \param path A string with the path of the directory which couldn't be created + * \return An initialized create directory failed exception + */ +- initWithClass: (Class)class_ + path: (OFString*)path; + +/** + * \return The errno from when the exception was created + */ +- (int)errNo; + +/** + * \return A string with the path of the file which couldn't be opened + */ +- (OFString*)path; +@end + /** * \brief An exception indicating that changing the mode of a file failed. */ @interface OFChangeFileModeFailedException: OFException { @@ -582,16 +620,16 @@ * \return The errno from when the exception was created */ - (int)errNo; /** - * \return A string of the source for the link + * \return A string with the source for the link */ - (OFString*)source; /** - * \return A string of the destination for the link + * \return A string with the destination for the link */ - (OFString*)destination; @end /** @@ -630,16 +668,16 @@ * \return The errno from when the exception was created */ - (int)errNo; /** - * \return A string of the source for the symlink + * \return A string with the source for the symlink */ - (OFString*)source; /** - * \return A string of the destination for the symlink + * \return A string with the destination for the symlink */ - (OFString*)destination; @end #endif Index: src/OFExceptions.m ================================================================== --- src/OFExceptions.m +++ src/OFExceptions.m @@ -512,10 +512,65 @@ - (int)errNo { return err; } @end + +@implementation OFCreateDirectoryFailedException ++ newWithClass: (Class)class__ + path: (OFString*)path_ +{ + return [[self alloc] initWithClass: class__ + path: path_]; +} + +- initWithClass: (Class)class__ +{ + @throw [OFNotImplementedException newWithClass: isa + selector: _cmd]; +} + +- initWithClass: (Class)class__ + path: (OFString*)path_ +{ + self = [super initWithClass: class__]; + + path = [path_ copy]; + err = GET_ERR; + + return self; +} + +- (void)dealloc +{ + [path release]; + + [super dealloc]; +} + +- (OFString*)string +{ + if (string != nil) + return string; + + string = [[OFString alloc] initWithFormat: + @"Failed to create directory %s in class %s! " ERRFMT, + [path cString], [class_ className], ERRPARAM]; + + return string; +} + +- (int)errNo +{ + return err; +} + +- (OFString*)path +{ + return path; +} +@end @implementation OFChangeFileModeFailedException + newWithClass: (Class)class__ path: (OFString*)path_ mode: (mode_t)mode_