Index: src/OFFileURLHandler.m ================================================================== --- src/OFFileURLHandler.m +++ src/OFFileURLHandler.m @@ -57,11 +57,11 @@ #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" -#import "OFLinkFailedException.h" +#import "OFLinkItemFailedException.h" #import "OFMoveItemFailedException.h" #import "OFNotImplementedException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" @@ -1352,11 +1352,11 @@ # ifndef OF_WINDOWS OFStringEncoding encoding = [OFLocale encoding]; if (link([sourcePath cStringWithEncoding: encoding], [destinationPath cStringWithEncoding: encoding]) != 0) - @throw [OFLinkFailedException + @throw [OFLinkItemFailedException exceptionWithSourceURL: source destinationURL: destination errNo: errno]; # else if (createHardLinkWFuncPtr == NULL) @@ -1363,11 +1363,11 @@ @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; if (!createHardLinkWFuncPtr(destinationPath.UTF16String, sourcePath.UTF16String, NULL)) - @throw [OFLinkFailedException + @throw [OFLinkItemFailedException exceptionWithSourceURL: source destinationURL: destination errNo: retrieveError()]; # endif Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -191,11 +191,11 @@ #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFInvalidJSONException.h" #import "OFInvalidServerResponseException.h" -#import "OFLinkFailedException.h" +#import "OFLinkItemFailedException.h" #ifdef OF_HAVE_SOCKETS # import "OFListenFailedException.h" #endif #ifdef OF_HAVE_PLUGINS # import "OFLoadPluginFailedException.h" Index: src/exceptions/Makefile ================================================================== --- src/exceptions/Makefile +++ src/exceptions/Makefile @@ -18,11 +18,11 @@ OFInvalidArgumentException.m \ OFInvalidEncodingException.m \ OFInvalidFormatException.m \ OFInvalidJSONException.m \ OFInvalidServerResponseException.m \ - OFLinkFailedException.m \ + OFLinkItemFailedException.m \ OFLockFailedException.m \ OFMalformedXMLException.m \ OFMoveItemFailedException.m \ OFNotImplementedException.m \ OFNotOpenException.m \ DELETED src/exceptions/OFLinkFailedException.h Index: src/exceptions/OFLinkFailedException.h ================================================================== --- src/exceptions/OFLinkFailedException.h +++ /dev/null @@ -1,79 +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 OFURL; - -/** - * @class OFLinkFailedException \ - * OFLinkFailedException.h ObjFW/OFLinkFailedException.h - * - * @brief An exception indicating that creating a link failed. - */ -@interface OFLinkFailedException: OFException -{ - OFURL *_sourceURL, *_destinationURL; - int _errNo; - OF_RESERVE_IVARS(OFLinkFailedException, 4) -} - -/** - * @brief A URL with the source for the link. - */ -@property (readonly, nonatomic) OFURL *sourceURL; - -/** - * @brief A URL with the destination for the link. - */ -@property (readonly, nonatomic) OFURL *destinationURL; - -/** - * @brief The errno of the error that occurred. - */ -@property (readonly, nonatomic) int errNo; - -/** - * @brief Creates a new, autoreleased link failed exception. - * - * @param sourceURL The source for the link - * @param destinationURL The destination for the link - * @param errNo The errno of the error that occurred - * @return A new, autoreleased link failed exception - */ -+ (instancetype)exceptionWithSourceURL: (OFURL *)sourceURL - destinationURL: (OFURL *)destinationURL - errNo: (int)errNo; - -+ (instancetype)exception OF_UNAVAILABLE; - -/** - * @brief Initializes an already allocated link failed exception. - * - * @param sourceURL The source for the link - * @param destinationURL The destination for the link - * @param errNo The errno of the error that occurred - * @return An initialized link failed exception - */ -- (instancetype)initWithSourceURL: (OFURL*)sourceURL - destinationURL: (OFURL *)destinationURL - errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - -- (instancetype)init OF_UNAVAILABLE; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFLinkFailedException.m Index: src/exceptions/OFLinkFailedException.m ================================================================== --- src/exceptions/OFLinkFailedException.m +++ /dev/null @@ -1,76 +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 "OFLinkFailedException.h" -#import "OFString.h" -#import "OFURL.h" - -@implementation OFLinkFailedException -@synthesize sourceURL = _sourceURL, destinationURL = _destinationURL; -@synthesize errNo = _errNo; - -+ (instancetype)exception -{ - OF_UNRECOGNIZED_SELECTOR -} - -+ (instancetype)exceptionWithSourceURL: (OFURL *)sourceURL - destinationURL: (OFURL *)destinationURL - errNo: (int)errNo -{ - return [[[self alloc] initWithSourceURL: sourceURL - destinationURL: destinationURL - errNo: errNo] autorelease]; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (instancetype)initWithSourceURL: (OFURL *)sourceURL - destinationURL: (OFURL *)destinationURL - errNo: (int)errNo -{ - self = [super init]; - - @try { - _sourceURL = [sourceURL copy]; - _destinationURL = [destinationURL copy]; - _errNo = errNo; - } @catch (id e) { - [self release]; - @throw e; - } - - return self; -} - -- (void)dealloc -{ - [_sourceURL release]; - [_destinationURL release]; - - [super dealloc]; -} - -- (OFString *)description -{ - return [OFString stringWithFormat: @"Failed to link file %@ to %@: %@", - _sourceURL, _destinationURL, OFStrError(_errNo)]; -} -@end ADDED src/exceptions/OFLinkItemFailedException.h Index: src/exceptions/OFLinkItemFailedException.h ================================================================== --- /dev/null +++ src/exceptions/OFLinkItemFailedException.h @@ -0,0 +1,79 @@ +/* + * 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 OFURL; + +/** + * @class OFLinkItemFailedException \ + * OFLinkItemFailedException.h ObjFW/OFLinkItemFailedException.h + * + * @brief An exception indicating that creating a link failed. + */ +@interface OFLinkItemFailedException: OFException +{ + OFURL *_sourceURL, *_destinationURL; + int _errNo; + OF_RESERVE_IVARS(OFLinkItemFailedException, 4) +} + +/** + * @brief A URL with the source for the link. + */ +@property (readonly, nonatomic) OFURL *sourceURL; + +/** + * @brief A URL with the destination for the link. + */ +@property (readonly, nonatomic) OFURL *destinationURL; + +/** + * @brief The errno of the error that occurred. + */ +@property (readonly, nonatomic) int errNo; + +/** + * @brief Creates a new, autoreleased link failed exception. + * + * @param sourceURL The source for the link + * @param destinationURL The destination for the link + * @param errNo The errno of the error that occurred + * @return A new, autoreleased link failed exception + */ ++ (instancetype)exceptionWithSourceURL: (OFURL *)sourceURL + destinationURL: (OFURL *)destinationURL + errNo: (int)errNo; + ++ (instancetype)exception OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated link failed exception. + * + * @param sourceURL The source for the link + * @param destinationURL The destination for the link + * @param errNo The errno of the error that occurred + * @return An initialized link failed exception + */ +- (instancetype)initWithSourceURL: (OFURL*)sourceURL + destinationURL: (OFURL *)destinationURL + errNo: (int)errNo OF_DESIGNATED_INITIALIZER; + +- (instancetype)init OF_UNAVAILABLE; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFLinkItemFailedException.m Index: src/exceptions/OFLinkItemFailedException.m ================================================================== --- /dev/null +++ src/exceptions/OFLinkItemFailedException.m @@ -0,0 +1,76 @@ +/* + * 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 "OFLinkItemFailedException.h" +#import "OFString.h" +#import "OFURL.h" + +@implementation OFLinkItemFailedException +@synthesize sourceURL = _sourceURL, destinationURL = _destinationURL; +@synthesize errNo = _errNo; + ++ (instancetype)exception +{ + OF_UNRECOGNIZED_SELECTOR +} + ++ (instancetype)exceptionWithSourceURL: (OFURL *)sourceURL + destinationURL: (OFURL *)destinationURL + errNo: (int)errNo +{ + return [[[self alloc] initWithSourceURL: sourceURL + destinationURL: destinationURL + errNo: errNo] autorelease]; +} + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} + +- (instancetype)initWithSourceURL: (OFURL *)sourceURL + destinationURL: (OFURL *)destinationURL + errNo: (int)errNo +{ + self = [super init]; + + @try { + _sourceURL = [sourceURL copy]; + _destinationURL = [destinationURL copy]; + _errNo = errNo; + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)dealloc +{ + [_sourceURL release]; + [_destinationURL release]; + + [super dealloc]; +} + +- (OFString *)description +{ + return [OFString stringWithFormat: @"Failed to link file %@ to %@: %@", + _sourceURL, _destinationURL, OFStrError(_errNo)]; +} +@end