Index: src/OFFileManager.m ================================================================== --- src/OFFileManager.m +++ src/OFFileManager.m @@ -43,11 +43,11 @@ #import "OFURLHandler.h" #import "OFChangeCurrentDirectoryPathFailedException.h" #import "OFCopyItemFailedException.h" #import "OFCreateDirectoryFailedException.h" -#import "OFGetCurrentDirectoryPathFailedException.h" +#import "OFGetCurrentDirectoryFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFMoveItemFailedException.h" #import "OFNotImplementedException.h" #import "OFOutOfMemoryException.h" @@ -169,11 +169,11 @@ encoding: [OFLocale encoding]]; # else char buffer[PATH_MAX]; if ((getcwd(buffer, PATH_MAX)) == NULL) - @throw [OFGetCurrentDirectoryPathFailedException + @throw [OFGetCurrentDirectoryFailedException exceptionWithErrNo: errno]; # ifdef OF_DJGPP /* * For some reason, getcwd() returns forward slashes on DJGPP, even Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -174,11 +174,11 @@ # import "OFDeleteWindowsRegistryKeyFailedException.h" # import "OFDeleteWindowsRegistryValueFailedException.h" #endif #import "OFEnumerationMutationException.h" #ifdef OF_HAVE_FILES -# import "OFGetCurrentDirectoryPathFailedException.h" +# import "OFGetCurrentDirectoryFailedException.h" #endif #import "OFGetOptionFailedException.h" #ifdef OF_WINDOWS # import "OFGetWindowsRegistryValueFailedException.h" #endif Index: src/exceptions/Makefile ================================================================== --- src/exceptions/Makefile +++ src/exceptions/Makefile @@ -49,11 +49,11 @@ ${USE_SRCS_FILES} \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} \ ${USE_SRCS_THREADS} \ ${USE_SRCS_WINDOWS} -SRCS_FILES = OFGetCurrentDirectoryPathFailedException.m +SRCS_FILES = OFGetCurrentDirectoryFailedException.m SRCS_PLUGINS = OFLoadPluginFailedException.m SRCS_SOCKETS = OFAcceptFailedException.m \ OFAlreadyConnectedException.m \ OFBindFailedException.m \ OFConnectionFailedException.m \ ADDED src/exceptions/OFGetCurrentDirectoryFailedException.h Index: src/exceptions/OFGetCurrentDirectoryFailedException.h ================================================================== --- src/exceptions/OFGetCurrentDirectoryFailedException.h +++ src/exceptions/OFGetCurrentDirectoryFailedException.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFException.h" + +OF_ASSUME_NONNULL_BEGIN + +/** + * @class OFGetCurrentDirectoryFailedException \ + * OFGetCurrentDirectoryFailedException.h \ + * ObjFW/OFGetCurrentDirectoryFailedException.h + * + * @brief An exception indicating that getting the current directory path + * failed. + */ +@interface OFGetCurrentDirectoryFailedException: OFException +{ + int _errNo; + OF_RESERVE_IVARS(OFGetCurrentDirectoryFailedException, 4) +} + +/** + * @brief The errno of the error that occurred. + */ +@property (readonly, nonatomic) int errNo; + +/** + * @brief Creates a new, autoreleased get current directory path failed + * exception. + * + * @param errNo The errno of the error that occurred + * @return A new, autoreleased get current directory failed exception + */ ++ (instancetype)exceptionWithErrNo: (int)errNo; + ++ (instancetype)exception OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated get current directory path failed + * exception. + * + * @param errNo The errno of the error that occurred + * @return An initialized get current directory path failed exception + */ +- (instancetype)initWithErrNo: (int)errNo OF_DESIGNATED_INITIALIZER; + +- (instancetype)init OF_UNAVAILABLE; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFGetCurrentDirectoryFailedException.m Index: src/exceptions/OFGetCurrentDirectoryFailedException.m ================================================================== --- src/exceptions/OFGetCurrentDirectoryFailedException.m +++ src/exceptions/OFGetCurrentDirectoryFailedException.m @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "OFGetCurrentDirectoryFailedException.h" +#import "OFString.h" + +@implementation OFGetCurrentDirectoryFailedException +@synthesize errNo = _errNo; + ++ (instancetype)exceptionWithErrNo: (int)errNo +{ + return [[[self alloc] initWithErrNo: errNo] autorelease]; +} + ++ (instancetype)exception +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (instancetype)initWithErrNo: (int)errNo +{ + self = [super init]; + + _errNo = errNo; + + return self; +} + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} + +- (OFString *)description +{ + return [OFString stringWithFormat: + @"Getting the current directory path failed: %@", + OFStrError(_errNo)]; +} +@end DELETED src/exceptions/OFGetCurrentDirectoryPathFailedException.h Index: src/exceptions/OFGetCurrentDirectoryPathFailedException.h ================================================================== --- src/exceptions/OFGetCurrentDirectoryPathFailedException.h +++ src/exceptions/OFGetCurrentDirectoryPathFailedException.h @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#import "OFException.h" - -OF_ASSUME_NONNULL_BEGIN - -/** - * @class OFGetCurrentDirectoryPathFailedException \ - * OFGetCurrentDirectoryPathFailedException.h \ - * ObjFW/OFGetCurrentDirectoryPathFailedException.h - * - * @brief An exception indicating that getting the current directory path - * failed. - */ -@interface OFGetCurrentDirectoryPathFailedException: OFException -{ - int _errNo; - OF_RESERVE_IVARS(OFGetCurrentDirectoryPathFailedException, 4) -} - -/** - * @brief The errno of the error that occurred. - */ -@property (readonly, nonatomic) int errNo; - -/** - * @brief Creates a new, autoreleased get current directory path failed - * exception. - * - * @param errNo The errno of the error that occurred - * @return A new, autoreleased get current directory failed exception - */ -+ (instancetype)exceptionWithErrNo: (int)errNo; - -+ (instancetype)exception OF_UNAVAILABLE; - -/** - * @brief Initializes an already allocated get current directory path failed - * exception. - * - * @param errNo The errno of the error that occurred - * @return An initialized get current directory path failed exception - */ -- (instancetype)initWithErrNo: (int)errNo OF_DESIGNATED_INITIALIZER; - -- (instancetype)init OF_UNAVAILABLE; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFGetCurrentDirectoryPathFailedException.m Index: src/exceptions/OFGetCurrentDirectoryPathFailedException.m ================================================================== --- src/exceptions/OFGetCurrentDirectoryPathFailedException.m +++ src/exceptions/OFGetCurrentDirectoryPathFailedException.m @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#include "config.h" - -#import "OFGetCurrentDirectoryPathFailedException.h" -#import "OFString.h" - -@implementation OFGetCurrentDirectoryPathFailedException -@synthesize errNo = _errNo; - -+ (instancetype)exceptionWithErrNo: (int)errNo -{ - return [[[self alloc] initWithErrNo: errNo] autorelease]; -} - -+ (instancetype)exception -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (instancetype)initWithErrNo: (int)errNo -{ - self = [super init]; - - _errNo = errNo; - - return self; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (OFString *)description -{ - return [OFString stringWithFormat: - @"Getting the current directory path failed: %@", - OFStrError(_errNo)]; -} -@end