Overview
Comment: | Add exception for currentDirectoryPath failing
This also changes OFFileManager to use a buffer with getcwd() rather |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d133fa0a89f11609e94d8d02d38e50a1 |
User & Date: | js on 2018-02-11 14:33:16 |
Other Links: | manifest | tags |
Context
2018-02-11
| ||
14:47 | -Wno-gnu-imaginary-constant only with complex.h check-in: e3368ee189 user: js tags: trunk | |
14:33 | Add exception for currentDirectoryPath failing check-in: d133fa0a89 user: js tags: trunk | |
12:15 | Make OFNumber a subclass of OFValue check-in: 612cd94090 user: js tags: trunk | |
Changes
Modified src/OFFileManager.m from [cd0c9b6190] to [06ca9c602c].
︙ | ︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #import "OFString.h" #import "OFSystemInfo.h" #import "OFURL.h" #import "OFURLHandler.h" #import "OFChangeCurrentDirectoryPathFailedException.h" #import "OFCopyItemFailedException.h" #import "OFInvalidArgumentException.h" #import "OFMoveItemFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFRemoveItemFailedException.h" #import "OFRetrieveItemAttributesFailedException.h" #import "OFUndefinedKeyException.h" | > | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #import "OFString.h" #import "OFSystemInfo.h" #import "OFURL.h" #import "OFURLHandler.h" #import "OFChangeCurrentDirectoryPathFailedException.h" #import "OFCopyItemFailedException.h" #import "OFGetCurrentDirectoryPathFailedException.h" #import "OFInvalidArgumentException.h" #import "OFMoveItemFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFRemoveItemFailedException.h" #import "OFRetrieveItemAttributesFailedException.h" #import "OFUndefinedKeyException.h" |
︙ | ︙ | |||
155 156 157 158 159 160 161 | return nil; } return [OFString stringWithCString: buffer encoding: [OFLocalization encoding]]; #else | < | > | > | | | < < < < < | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | return nil; } return [OFString stringWithCString: buffer encoding: [OFLocalization encoding]]; #else char buffer[PATH_MAX]; if ((getcwd(buffer, PATH_MAX)) == NULL) @throw [OFGetCurrentDirectoryPathFailedException exceptionWithErrNo: errno]; return [OFString stringWithCString: buffer encoding: [OFLocalization encoding]]; #endif } - (OFURL *)currentDirectoryURL { OFMutableURL *URL = [OFMutableURL URL]; void *pool = objc_autoreleasePoolPush(); |
︙ | ︙ |
Modified src/ObjFW.h from [01ae715851] to [a25671fef1].
︙ | ︙ | |||
136 137 138 139 140 141 142 143 144 145 146 147 148 149 | #ifdef OF_HAVE_SOCKETS # import "OFConnectionFailedException.h" #endif #import "OFCopyItemFailedException.h" #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" #import "OFEnumerationMutationException.h" #import "OFGetOptionFailedException.h" #import "OFHashAlreadyCalculatedException.h" #ifdef OF_HAVE_SOCKETS # import "OFHTTPRequestFailedException.h" #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" | > > > | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | #ifdef OF_HAVE_SOCKETS # import "OFConnectionFailedException.h" #endif #import "OFCopyItemFailedException.h" #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" #import "OFEnumerationMutationException.h" #ifdef OF_HAVE_FILES # import "OFGetCurrentDirectoryPathFailedException.h" #endif #import "OFGetOptionFailedException.h" #import "OFHashAlreadyCalculatedException.h" #ifdef OF_HAVE_SOCKETS # import "OFHTTPRequestFailedException.h" #endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" |
︙ | ︙ |
Modified src/exceptions/Makefile from [72ca6fab0d] to [667f570482].
︙ | ︙ | |||
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | OFUnboundPrefixException.m \ OFUndefinedKeyException.m \ OFUnknownXMLEntityException.m \ OFUnlockFailedException.m \ OFUnsupportedProtocolException.m \ OFUnsupportedVersionException.m \ OFWriteFailedException.m \ ${USE_SRCS_SOCKETS} \ ${USE_SRCS_THREADS} \ ${USE_SRCS_PLUGINS} SRCS_SOCKETS = OFAcceptFailedException.m \ OFAddressTranslationFailedException.m \ OFAlreadyConnectedException.m \ OFBindFailedException.m \ OFConnectionFailedException.m \ OFHTTPRequestFailedException.m \ OFListenFailedException.m \ | > > | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | OFUnboundPrefixException.m \ OFUndefinedKeyException.m \ OFUnknownXMLEntityException.m \ OFUnlockFailedException.m \ OFUnsupportedProtocolException.m \ OFUnsupportedVersionException.m \ OFWriteFailedException.m \ ${USE_SRCS_FILES} \ ${USE_SRCS_SOCKETS} \ ${USE_SRCS_THREADS} \ ${USE_SRCS_PLUGINS} SRCS_FILES = OFGetCurrentDirectoryPathFailedException.m SRCS_SOCKETS = OFAcceptFailedException.m \ OFAddressTranslationFailedException.m \ OFAlreadyConnectedException.m \ OFBindFailedException.m \ OFConnectionFailedException.m \ OFHTTPRequestFailedException.m \ OFListenFailedException.m \ |
︙ | ︙ |
Added src/exceptions/OFGetCurrentDirectoryPathFailedException.h version [db0faef208].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018 * Jonathan Schleifer <js@heap.zone> * * 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; } /*! * @brief The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; + (instancetype)exception OF_UNAVAILABLE; /*! * @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)init 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; @end OF_ASSUME_NONNULL_END |
Added src/exceptions/OFGetCurrentDirectoryPathFailedException.m version [ed47e223fe].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, * 2018 * Jonathan Schleifer <js@heap.zone> * * 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)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithErrNo: (int)errNo { return [[[self alloc] initWithErrNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithErrNo: (int)errNo { self = [super init]; _errNo = errNo; return self; } - (OFString *)description { return [OFString stringWithFormat: @"Getting the current directory path failed: %@", of_strerror(_errNo)]; } @end |
Modified tests/OFURLTests.m from [cef8991d90] to [0de5c9643a].
︙ | ︙ | |||
101 102 103 104 105 106 107 | EXPECT_EXCEPTION( @"+[URLWithString:relativeToURL:] fails with invalid characters #4", OFInvalidFormatException, [OFURL URLWithString: @"#`" relativeToURL: u1]) #ifdef OF_HAVE_FILES | | | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | EXPECT_EXCEPTION( @"+[URLWithString:relativeToURL:] fails with invalid characters #4", OFInvalidFormatException, [OFURL URLWithString: @"#`" relativeToURL: u1]) #ifdef OF_HAVE_FILES TEST(@"+[fileURLWithPath:]", [[[OFURL fileURLWithPath: @"testfile.txt"] fileSystemRepresentation] isEqual: [[[OFFileManager defaultManager] currentDirectoryPath] stringByAppendingPathComponent: @"testfile.txt"]]) #endif TEST(@"-[string]", [[u1 string] isEqual: url_str] && |
︙ | ︙ |