Overview
Comment: | Revert "OFOpenItemFailedException: Remove path"
This caused more problems than it solved. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
1185c1cd3df11d451ee5d07a9f1eb673 |
User & Date: | js on 2022-04-25 20:09:27 |
Other Links: | manifest | tags |
Context
2022-05-20
| ||
09:36 | OFHTTPServer: Send 400 on invalid path/query check-in: f67621fa4d user: js tags: trunk | |
2022-04-25
| ||
20:09 | Revert "OFOpenItemFailedException: Remove path" check-in: 1185c1cd3d user: js tags: trunk | |
19:37 | OFNotification: Make init unavailable check-in: cc7dbe6a83 user: js tags: trunk | |
19:09 | OFOpenItemFailedException: Remove path check-in: c62f1c55ac user: js tags: trunk | |
Changes
Modified src/OFFile.m from [ca29a7a55a] to [6d43aa3c50].
︙ | ︙ | |||
234 235 236 237 238 239 240 | handle = open( [path cStringWithEncoding: [OFLocale encoding]], flags, 0666); # endif if (handle == -1) @throw [OFOpenItemFailedException | | | | < | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | handle = open( [path cStringWithEncoding: [OFLocale encoding]], flags, 0666); # endif if (handle == -1) @throw [OFOpenItemFailedException exceptionWithPath: path mode: mode errNo: errno]; #else handle = OFAllocMemory(1, sizeof(*handle)); @try { if ((flags = parseMode(mode.UTF8String, &handle->append)) == -1) @throw [OFInvalidArgumentException exception]; if ((handle->handle = Open([path cStringWithEncoding: [OFLocale encoding]], flags)) == 0) { int errNo; switch (IoErr()) { case ERROR_OBJECT_IN_USE: case ERROR_DISK_NOT_VALIDATED: errNo = EBUSY; break; case ERROR_OBJECT_NOT_FOUND: |
︙ | ︙ | |||
269 270 271 272 273 274 275 | errNo = EACCES; break; default: errNo = 0; break; } | < | | | < < | | | | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | errNo = EACCES; break; default: errNo = 0; break; } @throw [OFOpenItemFailedException exceptionWithPath: path mode: mode errNo: errNo]; } if (handle->append) { # if defined(OF_MORPHOS) if (Seek64(handle->handle, 0, OFFSET_END) == -1) { # elif defined(OF_AMIGAOS4) if (ChangeFilePosition(handle->handle, 0, OFFSET_END) == -1) { # else if (Seek(handle->handle, 0, OFFSET_END) == -1) { # endif Close(handle->handle); @throw [OFOpenItemFailedException exceptionWithPath: path mode: mode errNo: EIO]; } } Forbid(); handle->previous = NULL; handle->next = firstHandle; |
︙ | ︙ |
Modified src/OFString.m from [f2f791550d] to [05a5b5b79b].
︙ | ︙ | |||
1002 1003 1004 1005 1006 1007 1008 | OFFile *file = nil; @try { fileSize = [[OFFileManager defaultManager] attributesOfItemAtPath: path].fileSize; } @catch (OFRetrieveItemAttributesFailedException *e) { @throw [OFOpenItemFailedException | | | | | 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 | OFFile *file = nil; @try { fileSize = [[OFFileManager defaultManager] attributesOfItemAtPath: path].fileSize; } @catch (OFRetrieveItemAttributesFailedException *e) { @throw [OFOpenItemFailedException exceptionWithPath: path mode: @"r" errNo: e.errNo]; } objc_autoreleasePoolPop(pool); # if ULLONG_MAX > SIZE_MAX if (fileSize > SIZE_MAX) @throw [OFOutOfRangeException exception]; |
︙ | ︙ |
Modified src/OFZIPArchive.m from [b017bd11e7] to [2bbedc5f4d].
︙ | ︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #import "OFInflate64Stream.h" #import "OFChecksumMismatchException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFSeekFailedException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedVersionException.h" #import "OFWriteFailedException.h" /* | > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #import "OFInflate64Stream.h" #import "OFChecksumMismatchException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFSeekFailedException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedVersionException.h" #import "OFWriteFailedException.h" /* |
︙ | ︙ | |||
437 438 439 440 441 442 443 | if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_mode != modeRead) @throw [OFInvalidArgumentException exception]; if ((entry = [_pathToEntryMap objectForKey: path]) == nil) | | > > | 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_mode != modeRead) @throw [OFInvalidArgumentException exception]; if ((entry = [_pathToEntryMap objectForKey: path]) == nil) @throw [OFOpenItemFailedException exceptionWithPath: path mode: @"r" errNo: ENOENT]; [self of_closeLastReturnedStream]; offset64 = entry.of_localFileHeaderOffset; if (offset64 < 0 || (OFFileOffset)offset64 != offset64) @throw [OFOutOfRangeException exception]; |
︙ | ︙ | |||
491 492 493 494 495 496 497 | if (_mode != modeWrite && _mode != modeAppend) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); entry = [[entry_ mutableCopy] autorelease]; if ([_pathToEntryMap objectForKey: entry.fileName] != nil) | | > > > | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | if (_mode != modeWrite && _mode != modeAppend) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); entry = [[entry_ mutableCopy] autorelease]; if ([_pathToEntryMap objectForKey: entry.fileName] != nil) @throw [OFOpenItemFailedException exceptionWithPath: entry.fileName mode: @"w" errNo: EEXIST]; if (entry.compressionMethod != OFZIPArchiveEntryCompressionMethodNone) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; [self of_closeLastReturnedStream]; |
︙ | ︙ |
Modified src/exceptions/OFOpenItemFailedException.h from [bc86e5de05] to [bf32fbec46].
︙ | ︙ | |||
23 24 25 26 27 28 29 | * @class OFOpenItemFailedException \ * OFOpenItemFailedException.h ObjFW/OFOpenItemFailedException.h * * @brief An exception indicating an item could not be opened. */ @interface OFOpenItemFailedException: OFException { | | | > | > > > > > | 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 | * @class OFOpenItemFailedException \ * OFOpenItemFailedException.h ObjFW/OFOpenItemFailedException.h * * @brief An exception indicating an item could not be opened. */ @interface OFOpenItemFailedException: OFException { OFURL *_Nullable _URL; OFString *_Nullable _path; OFString *_mode; int _errNo; } /** * @brief The URL of the item which could not be opened. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFURL *URL; /** * @brief The path of the item which could not be opened. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *path; /** * @brief The mode in which the item should have been opened. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *mode; /** |
︙ | ︙ | |||
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | * @param errNo The errno of the error that occurred * @return A new, autoreleased open item failed exception */ + (instancetype)exceptionWithURL: (OFURL *)URL mode: (nullable OFString *)mode errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated open item failed exception. * * @param URL The URL of the item which could not be opened * @param mode A string with the mode in which the item should have been opened * @param errNo The errno of the error that occurred * @return An initialized open item failed exception */ - (instancetype)initWithURL: (OFURL *)URL mode: (nullable OFString *)mode errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END | > > > > > > > > > > > > > > > > > > > > > > > > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | * @param errNo The errno of the error that occurred * @return A new, autoreleased open item failed exception */ + (instancetype)exceptionWithURL: (OFURL *)URL mode: (nullable OFString *)mode errNo: (int)errNo; /** * @brief Creates a new, autoreleased open item failed exception. * * @param path The path of the item which could not be opened * @param mode A string with the mode in which the item should have been opened * @param errNo The errno of the error that occurred * @return A new, autoreleased open item failed exception */ + (instancetype)exceptionWithPath: (OFString *)path mode: (nullable OFString *)mode errNo: (int)errNo; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated open item failed exception. * * @param URL The URL of the item which could not be opened * @param mode A string with the mode in which the item should have been opened * @param errNo The errno of the error that occurred * @return An initialized open item failed exception */ - (instancetype)initWithURL: (OFURL *)URL mode: (nullable OFString *)mode errNo: (int)errNo; /** * @brief Initializes an already allocated open item failed exception. * * @param path The path of the item which could not be opened * @param mode A string with the mode in which the item should have been opened * @param errNo The errno of the error that occurred * @return An initialized open item failed exception */ - (instancetype)initWithPath: (OFString *)path mode: (nullable OFString *)mode errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFOpenItemFailedException.m from [1a7c4cc489] to [2b4ec7a8b3].
︙ | ︙ | |||
16 17 18 19 20 21 22 | #include "config.h" #import "OFOpenItemFailedException.h" #import "OFString.h" #import "OFURL.h" @implementation OFOpenItemFailedException | | > > > > > > > > > | 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 | #include "config.h" #import "OFOpenItemFailedException.h" #import "OFString.h" #import "OFURL.h" @implementation OFOpenItemFailedException @synthesize URL = _URL, path = _path, mode = _mode, errNo = _errNo; + (instancetype)exceptionWithURL: (OFURL *)URL mode: (OFString *)mode errNo: (int)errNo { return [[[self alloc] initWithURL: URL mode: mode errNo: errNo] autorelease]; } + (instancetype)exceptionWithPath: (OFString *)path mode: (OFString *)mode errNo: (int)errNo { return [[[self alloc] initWithPath: path mode: mode errNo: errNo] autorelease]; } + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } - (instancetype)initWithURL: (OFURL *)URL |
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (void)dealloc { [_URL release]; [_mode release]; [super dealloc]; } - (OFString *)description { if (_mode != nil) return [OFString stringWithFormat: @"Failed to open item %@ with mode %@: %@", | > > > > > > > > > > > > > > > > > > > > > > > > > > | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode errNo: (int)errNo { self = [super init]; @try { _path = [path copy]; _mode = [mode copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (void)dealloc { [_URL release]; [_path release]; [_mode release]; [super dealloc]; } - (OFString *)description { id item = nil; if (_URL != nil) item = _URL; else if (_path != nil) item = _path; if (_mode != nil) return [OFString stringWithFormat: @"Failed to open item %@ with mode %@: %@", item, _mode, OFStrError(_errNo)]; else return [OFString stringWithFormat: @"Failed to open item %@: %@", item, OFStrError(_errNo)]; } @end |