Comment: | Add OFURLHandler |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
31e602a476d0c2a087686c5f3c034673 |
User & Date: | js on 2017-11-13 01:18:34 |
Other Links: | manifest | tags |
2017-11-13
| ||
01:42 | Fix -[OFURL fileURLWithPath:] on Windows check-in: fde127afd9 user: js tags: trunk | |
01:18 | Add OFURLHandler check-in: 31e602a476 user: js tags: trunk | |
2017-11-12
| ||
21:42 | OFFileManager: Symlinks take a destination path check-in: 9db4db82ed user: js tags: trunk | |
Modified configure.ac from [1919a82c3d] to [49cf0ecee8].
︙ | ︙ | |||
902 903 904 905 906 907 908 909 910 911 912 913 914 915 | AC_MSG_RESULT($atomic_ops) AC_ARG_ENABLE(files, AS_HELP_STRING([--disable-files], [disable file support])) AS_IF([test x"$enable_files" != x"no"], [ AC_DEFINE(OF_HAVE_FILES, 1, [Whether we have files]) AC_SUBST(USE_SRCS_FILES, '${SRCS_FILES}') AC_SUBST(OFHASH, "ofhash") AC_SUBST(OFZIP, "ofzip") case "$host_os" in msdosdjgpp*) dnl DJGPP has the type, but it's not really usable. ;; | > | 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 | AC_MSG_RESULT($atomic_ops) AC_ARG_ENABLE(files, AS_HELP_STRING([--disable-files], [disable file support])) AS_IF([test x"$enable_files" != x"no"], [ AC_DEFINE(OF_HAVE_FILES, 1, [Whether we have files]) AC_SUBST(USE_SRCS_FILES, '${SRCS_FILES}') AC_SUBST(USE_SRCS_FILES_NOINCLUDE, '${SRCS_FILES_NOINCLUDE}') AC_SUBST(OFHASH, "ofhash") AC_SUBST(OFZIP, "ofzip") case "$host_os" in msdosdjgpp*) dnl DJGPP has the type, but it's not really usable. ;; |
︙ | ︙ |
Modified extra.mk.in from [901b193c8a] to [153d2e2b77].
︙ | ︙ | |||
62 63 64 65 66 67 68 69 70 71 72 73 | RUN_TESTS = @RUN_TESTS@ TESTPLUGIN = @TESTPLUGIN@ TESTS_LIBS = @TESTS_LIBS@ TESTS_OBJCFLAGS = @TESTS_OBJCFLAGS@ UNICODE_M = @UNICODE_M@ USE_INCLUDES_ATOMIC = @USE_INCLUDES_ATOMIC@ USE_SRCS_FILES = @USE_SRCS_FILES@ USE_SRCS_PLUGINS = @USE_SRCS_PLUGINS@ USE_SRCS_SOCKETS = @USE_SRCS_SOCKETS@ USE_SRCS_THREADS = @USE_SRCS_THREADS@ WEAK_NSFOUNDATIONVERSIONNUMBER = @WEAK_NSFOUNDATIONVERSIONNUMBER@ WRAPPER = @WRAPPER@ | > | 62 63 64 65 66 67 68 69 70 71 72 73 74 | RUN_TESTS = @RUN_TESTS@ TESTPLUGIN = @TESTPLUGIN@ TESTS_LIBS = @TESTS_LIBS@ TESTS_OBJCFLAGS = @TESTS_OBJCFLAGS@ UNICODE_M = @UNICODE_M@ USE_INCLUDES_ATOMIC = @USE_INCLUDES_ATOMIC@ USE_SRCS_FILES = @USE_SRCS_FILES@ USE_SRCS_FILES_NOINCLUDE = @USE_SRCS_FILES_NOINCLUDE@ USE_SRCS_PLUGINS = @USE_SRCS_PLUGINS@ USE_SRCS_SOCKETS = @USE_SRCS_SOCKETS@ USE_SRCS_THREADS = @USE_SRCS_THREADS@ WEAK_NSFOUNDATIONVERSIONNUMBER = @WEAK_NSFOUNDATIONVERSIONNUMBER@ WRAPPER = @WRAPPER@ |
Modified src/Makefile from [3eed873b17] to [e79ddbdefe].
︙ | ︙ | |||
83 84 85 86 87 88 89 90 91 92 93 94 95 96 | OFSystemInfo.m \ OFTarArchive.m \ OFTarArchiveEntry.m \ OFThread.m \ OFTimer.m \ OFTriple.m \ OFURL.m \ OFXMLAttribute.m \ OFXMLCDATA.m \ OFXMLCharacters.m \ OFXMLComment.m \ OFXMLElement.m \ OFXMLElement+Serialization.m \ OFXMLElementBuilder.m \ | > | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | OFSystemInfo.m \ OFTarArchive.m \ OFTarArchiveEntry.m \ OFThread.m \ OFTimer.m \ OFTriple.m \ OFURL.m \ OFURLHandler.m \ OFXMLAttribute.m \ OFXMLCDATA.m \ OFXMLCharacters.m \ OFXMLComment.m \ OFXMLElement.m \ OFXMLElement+Serialization.m \ OFXMLElementBuilder.m \ |
︙ | ︙ | |||
111 112 113 114 115 116 117 118 119 120 121 122 123 124 | ${USE_SRCS_SOCKETS} \ ${USE_SRCS_THREADS} SRCS_FILES = OFFile.m \ OFFileManager.m \ OFINICategory.m \ OFINIFile.m \ OFSettings.m SRCS_PLUGINS = OFPlugin.m SRCS_SOCKETS = OFHTTPClient.m \ OFHTTPServer.m \ OFKernelEventObserver.m \ OFStreamSocket.m \ OFTCPSocket.m \ OFUDPSocket.m \ | > | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | ${USE_SRCS_SOCKETS} \ ${USE_SRCS_THREADS} SRCS_FILES = OFFile.m \ OFFileManager.m \ OFINICategory.m \ OFINIFile.m \ OFSettings.m SRCS_FILES_NOINCLUDE = OFURLHandler_file.m SRCS_PLUGINS = OFPlugin.m SRCS_SOCKETS = OFHTTPClient.m \ OFHTTPServer.m \ OFKernelEventObserver.m \ OFStreamSocket.m \ OFTCPSocket.m \ OFUDPSocket.m \ |
︙ | ︙ | |||
166 167 168 169 170 171 172 | OFMutableDictionary_hashtable.m \ OFMutableSet_hashtable.m \ OFMutableString_UTF8.m \ OFSet_hashtable.m \ OFString_UTF8.m \ ${AUTORELEASE_M} \ ${FOUNDATION_COMPAT_M} \ | | > | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | OFMutableDictionary_hashtable.m \ OFMutableSet_hashtable.m \ OFMutableString_UTF8.m \ OFSet_hashtable.m \ OFString_UTF8.m \ ${AUTORELEASE_M} \ ${FOUNDATION_COMPAT_M} \ ${INSTANCE_M} \ ${USE_SRCS_FILES_NOINCLUDE} SRCS_FILES += OFSettings_INIFile.m SRCS_SOCKETS += ${OFKERNELEVENTOBSERVER_EPOLL_M} \ ${OFKERNELEVENTOBSERVER_KQUEUE_M} \ ${OFKERNELEVENTOBSERVER_POLL_M} \ ${OFKERNELEVENTOBSERVER_SELECT_M} \ OFTCPSocket+SOCKS5.m |
︙ | ︙ |
Modified src/OFFileManager.h from [cba586493b] to [3fce9a9007].
︙ | ︙ | |||
507 508 509 510 511 512 513 | * name of the item. * * This method is not available on some systems. * * @note On Windows, this requires at least Windows Vista and administrator * privileges! * | | < | < | | | < | < | | | 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | * name of the item. * * This method is not available on some systems. * * @note On Windows, this requires at least Windows Vista and administrator * privileges! * * @param path The path to the item which should symbolically link to the target * @param target The target of the symbolic link */ - (void)createSymbolicLinkAtPath: (OFString *)path withDestinationPath: (OFString *)target; #endif /*! * @brief Creates a symbolic link for an item. * * The destination uRL must have a full path, which means it must include the * name of the item. * * This method is not available for all URLs. * * @note On Windows, this requires at least Windows Vista and administrator * privileges! * * @param URL The URL to the item which should symbolically link to the target * @param target The target of the symbolic link */ - (void)createSymbolicLinkAtURL: (OFURL *)URL withDestinationPath: (OFString *)target; @end @interface OFDictionary (FileAttributes) /*! * The @ref of_file_attribute_key_size key from the dictionary. * * Raises an @ref OFUndefinedKeyException if the key is missing. |
︙ | ︙ |
Modified src/OFFileManager.m from [344a7c8de0] to [bc7b129bce].
︙ | ︙ | |||
14 15 16 17 18 19 20 | * file. */ #include "config.h" #include <errno.h> | < < < < < < < < < < < < < < < < | < < < < < < < < < < | < < < < < < < < < < < < < < < < < < | 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 64 65 | * file. */ #include "config.h" #include <errno.h> #include "unistd_wrapper.h" #import "OFArray.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFLocalization.h" #import "OFNumber.h" #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" #import "OFUnsupportedProtocolException.h" #ifdef OF_WINDOWS # include <windows.h> # include <direct.h> # include <ntdef.h> #endif #ifdef OF_MORPHOS # define BOOL EXEC_BOOL # include <proto/dos.h> # include <proto/locale.h> # undef BOOL #endif @interface OFFileManager_default: OFFileManager @end static OFFileManager *defaultManager; const of_file_attribute_key_t of_file_attribute_key_size = @"of_file_attribute_key_size"; |
︙ | ︙ | |||
133 134 135 136 137 138 139 | const of_file_type_t of_file_type_symbolic_link = @"of_file_type_symbolic_link"; const of_file_type_t of_file_type_fifo = @"of_file_type_fifo"; const of_file_type_t of_file_type_character_special = @"of_file_type_character_special"; const of_file_type_t of_file_type_block_special = @"of_file_type_block_special"; const of_file_type_t of_file_type_socket = @"of_file_type_socket"; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | const of_file_type_t of_file_type_symbolic_link = @"of_file_type_symbolic_link"; const of_file_type_t of_file_type_fifo = @"of_file_type_fifo"; const of_file_type_t of_file_type_character_special = @"of_file_type_character_special"; const of_file_type_t of_file_type_block_special = @"of_file_type_block_special"; const of_file_type_t of_file_type_socket = @"of_file_type_socket"; #ifdef OF_MORPHOS static bool dirChanged = false; static BPTR originalDirLock = 0; OF_DESTRUCTOR() { if (dirChanged) UnLock(CurrentDir(originalDirLock)); } #endif static id attributeForKeyOrException(of_file_attributes_t attributes, of_file_attribute_key_t key) { id object = [attributes objectForKey: key]; if (object == nil) @throw [OFUndefinedKeyException exceptionWithObject: attributes key: key]; return object; } @implementation OFFileManager + (void)initialize { if (self != [OFFileManager class]) return; defaultManager = [[OFFileManager_default alloc] init]; } + (OFFileManager *)defaultManager { return defaultManager; } |
︙ | ︙ | |||
545 546 547 548 549 550 551 552 | [URL makeImmutable]; objc_autoreleasePoolPop(pool); return URL; } | | | < < | < < < < | < | < < < < < < < < < < < < < < | | | | > < < | > < < | < < < < < < < < < < < < < < | | < < < < < < < < < < < < < | < < < < < < | < < < < < < < < < < < < < < < < < | < < | < < < < < < < < < < < < < < < < < | | | > | > > | > | > > | < | > | > | | < < < | < < < < < < < < < > | < < < | < | > | > | < < | < | < < | < < | < | < < | | < > | | > | > | | | | | | | > < | < | < < | < | | < | | < | < < | < < | > > | < < | > | < < | | < < | | < | < < | < < | | < < < > | < < | > > | < | | < > < < < < < < < < < < < | < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < | | | | < | < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | < < < < < < < | < < < < < < < | < < < < < < < < | < < < < < < < | < < < < < < | < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 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 261 262 263 264 265 266 267 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 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | [URL makeImmutable]; objc_autoreleasePoolPop(pool); return URL; } - (of_file_attributes_t)attributesOfItemAtURL: (OFURL *)URL { OF_KINDOF(OFURLHandler *) URLHandler; if (URL == nil) @throw [OFInvalidArgumentException exception]; if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; return [URLHandler attributesOfItemAtURL: URL]; } - (of_file_attributes_t)attributesOfItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); of_file_attributes_t ret; ret = [self attributesOfItemAtURL: [OFURL fileURLWithPath: path]]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (void)setAttributes: (of_file_attributes_t)attributes ofItemAtURL: (OFURL *)URL { OF_KINDOF(OFURLHandler *) URLHandler; if (URL == nil) @throw [OFInvalidArgumentException exception]; if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; [URLHandler setAttributes: attributes ofItemAtURL: URL]; } - (void)setAttributes: (of_file_attributes_t)attributes ofItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); [self setAttributes: attributes ofItemAtURL: [OFURL fileURLWithPath: path]]; objc_autoreleasePoolPop(pool); } - (bool)fileExistsAtURL: (OFURL *)URL { OF_KINDOF(OFURLHandler *) URLHandler; if (URL == nil) @throw [OFInvalidArgumentException exception]; if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; return [URLHandler fileExistsAtURL: URL]; } - (bool)fileExistsAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); bool ret; ret = [self fileExistsAtURL: [OFURL fileURLWithPath: path]]; objc_autoreleasePoolPop(pool); return ret; } - (bool)directoryExistsAtURL: (OFURL *)URL { OF_KINDOF(OFURLHandler *) URLHandler; if (URL == nil) @throw [OFInvalidArgumentException exception]; if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; return [URLHandler directoryExistsAtURL: URL]; } - (bool)directoryExistsAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); bool ret; ret = [self directoryExistsAtURL: [OFURL fileURLWithPath: path]]; objc_autoreleasePoolPop(pool); return ret; } - (void)createDirectoryAtURL: (OFURL *)URL { OF_KINDOF(OFURLHandler *) URLHandler; if (URL == nil) @throw [OFInvalidArgumentException exception]; if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; [URLHandler createDirectoryAtURL: URL]; } - (void)createDirectoryAtURL: (OFURL *)URL_ createParents: (bool)createParents { void *pool = objc_autoreleasePoolPush(); OFMutableURL *URL = [[URL_ mutableCopy] autorelease]; OFArray OF_GENERIC(OFString *) *components; OFString *currentPath = nil; if (URL == nil) @throw [OFInvalidArgumentException exception]; if (!createParents) { [self createDirectoryAtURL: URL]; return; } components = [[URL URLEncodedPath] componentsSeparatedByString: @"/"]; for (OFString *component in components) { if (currentPath != nil) currentPath = [currentPath stringByAppendingFormat: @"/%@", component]; else currentPath = component; [URL setURLEncodedPath: currentPath]; if ([currentPath length] > 0 && ![self directoryExistsAtURL: URL]) [self createDirectoryAtURL: URL]; } objc_autoreleasePoolPop(pool); } - (void)createDirectoryAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); [self createDirectoryAtURL: [OFURL fileURLWithPath: path]]; objc_autoreleasePoolPop(pool); } - (void)createDirectoryAtPath: (OFString *)path createParents: (bool)createParents { void *pool = objc_autoreleasePoolPush(); [self createDirectoryAtURL: [OFURL fileURLWithPath: path] createParents: createParents]; objc_autoreleasePoolPop(pool); } - (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtURL: (OFURL *)URL { OF_KINDOF(OFURLHandler *) URLHandler; if (URL == nil) @throw [OFInvalidArgumentException exception]; if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; return [URLHandler contentsOfDirectoryAtURL: URL]; } - (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFArray OF_GENERIC(OFString *) *ret; ret = [self contentsOfDirectoryAtURL: [OFURL fileURLWithPath: path]]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } |
︙ | ︙ | |||
1320 1321 1322 1323 1324 1325 1326 | objc_autoreleasePoolPop(pool); } - (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination { | < < | | 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | objc_autoreleasePoolPop(pool); } - (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination { if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; if ([self fileExistsAtPath: destination]) @throw [OFMoveItemFailedException exceptionWithSourcePath: source destinationPath: destination errNo: EEXIST]; #if defined(OF_WINDOWS) void *pool = objc_autoreleasePoolPush(); |
︙ | ︙ | |||
1424 1425 1426 1427 1428 1429 1430 | [self moveItemAtPath: [source fileSystemRepresentation] toPath: [destination fileSystemRepresentation]]; objc_autoreleasePoolPop(pool); } | | | < | < | < | < < < | < < < < < < < < < < < < < < | < | < < < < | < | | | < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > > > > | > > > > > > > > > > > < < < < < | < < | < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < | | | > | < > | < > < < | < | < < < < < < < < < < < < < < > | | < | | < < < > | 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | [self moveItemAtPath: [source fileSystemRepresentation] toPath: [destination fileSystemRepresentation]]; objc_autoreleasePoolPop(pool); } - (void)removeItemAtURL: (OFURL *)URL { OF_KINDOF(OFURLHandler *) URLHandler; if (URL == nil) @throw [OFInvalidArgumentException exception]; if ((URLHandler = [OFURLHandler handlerForURL: URL]) == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; [URLHandler removeItemAtURL: URL]; } - (void)removeItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); [self removeItemAtURL: [OFURL fileURLWithPath: path]]; objc_autoreleasePoolPop(pool); } - (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination { void *pool = objc_autoreleasePoolPush(); OF_KINDOF(OFURLHandler *) URLHandler; if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; if (![[destination scheme] isEqual: [source scheme]]) @throw [OFInvalidArgumentException exception]; URLHandler = [OFURLHandler handlerForURL: source]; if (URLHandler == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: source]; [URLHandler linkItemAtURL: source toURL: destination]; objc_autoreleasePoolPop(pool); } #ifdef OF_FILE_MANAGER_SUPPORTS_LINKS - (void)linkItemAtPath: (OFString *)source toPath: (OFString *)destination { void *pool = objc_autoreleasePoolPush(); [self linkItemAtURL: [OFURL fileURLWithPath: source] toURL: [OFURL fileURLWithPath: destination]]; objc_autoreleasePoolPop(pool); } #endif - (void)createSymbolicLinkAtURL: (OFURL *)URL withDestinationPath: (OFString *)target { void *pool = objc_autoreleasePoolPush(); OF_KINDOF(OFURLHandler *) URLHandler; if (URL == nil || target == nil) @throw [OFInvalidArgumentException exception]; URLHandler = [OFURLHandler handlerForURL: URL]; if (URLHandler == nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; [URLHandler createSymbolicLinkAtURL: URL withDestinationPath: target]; objc_autoreleasePoolPop(pool); } #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS - (void)createSymbolicLinkAtPath: (OFString *)path withDestinationPath: (OFString *)target { void *pool = objc_autoreleasePoolPush(); [self createSymbolicLinkAtURL: [OFURL fileURLWithPath: path] withDestinationPath: target]; objc_autoreleasePoolPop(pool); } #endif @end @implementation OFDictionary (FileAttributes) - (uintmax_t)fileSize { return [attributeForKeyOrException(self, of_file_attribute_key_size) uIntMaxValue]; |
︙ | ︙ |
Modified src/OFURL.m from [4ba08a7ab6] to [7b7c6c2f3c].
︙ | ︙ | |||
18 19 20 21 22 23 24 | #include <stdlib.h> #include <string.h> #import "OFURL.h" #import "OFURL+Private.h" #import "OFArray.h" | < < < > > > > > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <stdlib.h> #include <string.h> #import "OFURL.h" #import "OFURL+Private.h" #import "OFArray.h" #import "OFNumber.h" #import "OFString.h" #import "OFXMLElement.h" #ifdef OF_HAVE_FILES # import "OFFileManager.h" # import "OFURLHandler_file.h" #endif #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" static OFCharacterSet *URLAllowedCharacterSet = nil; static OFCharacterSet *URLPathAllowedCharacterSet = nil; |
︙ | ︙ | |||
503 504 505 506 507 508 509 | } #ifdef OF_HAVE_FILES - (instancetype)initFileURLWithPath: (OFString *)path { @try { void *pool = objc_autoreleasePoolPush(); | < | | 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 | } #ifdef OF_HAVE_FILES - (instancetype)initFileURLWithPath: (OFString *)path { @try { void *pool = objc_autoreleasePoolPush(); bool isDirectory; isDirectory = ([path hasSuffix: OF_PATH_DELIMITER_STRING] || [OFURLHandler_file of_directoryExistsAtPath: path]); self = [self initFileURLWithPath: path isDirectory: isDirectory]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; |
︙ | ︙ |
Added src/OFURLHandler.h version [fa44f4ca93].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 * 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 "OFObject.h" #import "OFFileManager.h" OF_ASSUME_NONNULL_BEGIN @class OFString; @class OFURL; /*! * @class OFURLHandler OFURLHandler.h ObjFW/OFURLHandler.h * * @brief A handler for a URL scheme. */ @interface OFURLHandler: OFObject { OFString *_scheme; } /*! * The scheme this OFURLHandler handles. */ @property (readonly, nonatomic) OFString *scheme; /*! * @brief Registers the specified class as the handler for the specified scheme. * * If the same class is specified for two schemes, one instance of it is * created per scheme. * * @param class The class to register as the handler for the specified scheme * @param scheme The scheme for which to register the handler * @return Whether the class was successfully registered. If a handler for the * same scheme is already registered, registration fails. */ + (bool)registerClass: (Class)class forScheme: (OFString *)scheme; /*! * @brief Returns the handler for the specified URL. * * @return The handler for the specified URL. */ + (nullable OF_KINDOF(OFURLHandler *))handlerForURL: (OFURL *)URL; - (instancetype)init OF_UNAVAILABLE; /*! * @brief Initializes the handler for the specified scheme. * * @param scheme The scheme to initialize for * @return An initialized URL handler */ - (instancetype)initWithScheme: (OFString *)scheme OF_DESIGNATED_INITIALIZER; /*! * @brief Returns the attributes for the item at the specified URL. * * @param URL The URL to return the attributes for * @return A dictionary of attributes for the specified URL, with the keys of * type @ref of_file_attribute_key_t */ - (of_file_attributes_t)attributesOfItemAtURL: (OFURL *)URL; /*! * @brief Sets the attributes for the item at the specified URL. * * All attributes not part of the dictionary are left unchanged. * * @param attributes The attributes to set for the specified URL * @param URL The URL of the item to set the attributes for */ - (void)setAttributes: (of_file_attributes_t)attributes ofItemAtURL: (OFURL *)URL; /*! * @brief Checks whether a file exists at the specified URL. * * @param URL The URL to check * @return A boolean whether there is a file at the specified URL */ - (bool)fileExistsAtURL: (OFURL *)URL; /*! * @brief Checks whether a directory exists at the specified URL. * * @param URL The URL to check * @return A boolean whether there is a directory at the specified URL */ - (bool)directoryExistsAtURL: (OFURL *)URL; /*! * @brief Creates a directory at the specified URL. * * @param URL The URL of the directory to create */ - (void)createDirectoryAtURL: (OFURL *)URL; /*! * @brief Returns an array with the items in the specified directory. * * @note `.` and `..` are not part of the returned array. * * @param URL The URL to the directory whose items should be returned * @return An array of OFString with the items in the specified directory */ - (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtURL: (OFURL *)URL; /*! * @brief Removes the item at the specified URL. * * If the item at the specified URL is a directory, it is removed recursively. * * @param URL The URL to the item which should be removed */ - (void)removeItemAtURL: (OFURL *)URL; /*! * @brief Creates a hard link for the specified item. * * The destination URL must have a full path, which means it must include the * name of the item. * * This method is not available for all URLs. * * @param source The URL to the item for which a link should be created * @param destination The URL to the item which should link to the source */ - (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination; /*! * @brief Creates a symbolic link for an item. * * The destination uRL must have a full path, which means it must include the * name of the item. * * This method is not available for all URLs. * * @note On Windows, this requires at least Windows Vista and administrator * privileges! * * @param URL The URL to the item which should symbolically link to the target * @param target The target of the symbolic link */ - (void)createSymbolicLinkAtURL: (OFURL *)URL withDestinationPath: (OFString *)target; @end OF_ASSUME_NONNULL_END |
Added src/OFURLHandler.m version [d8db83adff].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 * 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 "OFURLHandler.h" #import "OFURL.h" #ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif #ifdef OF_HAVE_FILES # import "OFURLHandler_file.h" #endif static OFMutableDictionary OF_GENERIC(OFString *, OFURLHandler *) *handlers; #ifdef OF_HAVE_THREADS static OFMutex *mutex; #endif @implementation OFURLHandler @synthesize scheme = _scheme; + (void)initialize { if (self != [OFURLHandler class]) return; handlers = [[OFMutableDictionary alloc] init]; #ifdef OF_HAVE_THREADS mutex = [[OFMutex alloc] init]; #endif #ifdef OF_HAVE_FILES [self registerClass: [OFURLHandler_file class] forScheme: @"file"]; #endif } + (bool)registerClass: (Class)class forScheme: (OFString *)scheme { #ifdef OF_HAVE_THREADS [mutex lock]; @try { #endif OFURLHandler *handler; if ([handlers objectForKey: scheme] != nil) return false; handler = [[class alloc] initWithScheme: scheme]; @try { [handlers setObject: handler forKey: scheme]; } @finally { [handler release]; } #ifdef OF_HAVE_THREADS } @finally { [mutex unlock]; } #endif } + (OF_KINDOF(OFURLHandler *))handlerForURL: (OFURL *)URL { #ifdef OF_HAVE_THREADS [mutex lock]; @try { #endif return [handlers objectForKey: [URL scheme]]; #ifdef OF_HAVE_THREADS } @finally { [mutex unlock]; } #endif } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithScheme: (OFString *)scheme { self = [super init]; @try { _scheme = [scheme copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_scheme release]; [super dealloc]; } - (of_file_attributes_t)attributesOfItemAtURL: (OFURL *)URL { OF_UNRECOGNIZED_SELECTOR } - (void)setAttributes: (of_file_attributes_t)attributes ofItemAtURL: (OFURL *)URL { OF_UNRECOGNIZED_SELECTOR } - (bool)fileExistsAtURL: (OFURL *)URL { OF_UNRECOGNIZED_SELECTOR } - (bool)directoryExistsAtURL: (OFURL *)URL { OF_UNRECOGNIZED_SELECTOR } - (void)createDirectoryAtURL: (OFURL *)URL { OF_UNRECOGNIZED_SELECTOR } - (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtURL: (OFURL *)URL { OF_UNRECOGNIZED_SELECTOR } - (void)removeItemAtURL: (OFURL *)URL { OF_UNRECOGNIZED_SELECTOR } - (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination { OF_UNRECOGNIZED_SELECTOR } - (void)createSymbolicLinkAtURL: (OFURL *)destination withDestinationPath: (OFString *)source { OF_UNRECOGNIZED_SELECTOR } @end |
Added src/OFURLHandler_file.h version [cbc26cf269].
> > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 * 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 "OFURLHandler.h" OF_ASSUME_NONNULL_BEGIN @interface OFURLHandler_file: OFURLHandler + (bool)of_directoryExistsAtPath: (OFString *)path; @end OF_ASSUME_NONNULL_END |
Added src/OFURLHandler_file.m version [818810f60c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 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 261 262 263 264 265 266 267 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 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 * 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" #include <errno.h> #ifdef HAVE_DIRENT_H # include <dirent.h> #endif #include "unistd_wrapper.h" #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif #ifdef HAVE_PWD_H # include <pwd.h> #endif #ifdef HAVE_GRP_H # include <grp.h> #endif #import "OFURLHandler_file.h" #import "OFArray.h" #import "OFDate.h" #import "OFFile.h" #import "OFLocalization.h" #import "OFNumber.h" #import "OFURL.h" #ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" #import "OFInvalidArgumentException.h" #import "OFLinkFailedException.h" #import "OFNotImplementedException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFRemoveItemFailedException.h" #import "OFRetrieveItemAttributesFailedException.h" #import "OFSetItemAttributesFailedException.h" #ifdef OF_WINDOWS # include <windows.h> # include <direct.h> # include <ntdef.h> #endif #ifdef OF_MORPHOS # define BOOL EXEC_BOOL # include <proto/dos.h> # include <proto/locale.h> # undef BOOL #endif #if defined(OF_WINDOWS) typedef struct __stat64 of_stat_t; #elif defined(OF_MORPHOS) typedef struct { of_offset_t st_size; mode_t st_mode; of_time_interval_t st_atime, st_mtime, st_ctime; } of_stat_t; #elif defined(OF_HAVE_OFF64_T) typedef struct stat64 of_stat_t; #else typedef struct stat of_stat_t; #endif #ifndef S_ISLNK # define S_ISLNK(s) 0 #endif #if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS) static OFMutex *passwdMutex; #endif #if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS) && !defined(OF_WINDOWS) static OFMutex *readdirMutex; #endif #ifdef OF_WINDOWS static WINAPI BOOLEAN (*func_CreateSymbolicLinkW)(LPCWSTR, LPCWSTR, DWORD); #endif static int of_stat(OFString *path, of_stat_t *buffer) { #if defined(OF_WINDOWS) return _wstat64([path UTF16String], buffer); #elif defined(OF_MORPHOS) BPTR lock; struct FileInfoBlock fib; of_time_interval_t timeInterval; struct Locale *locale; if ((lock = Lock([path cStringWithEncoding: [OFLocalization encoding]], SHARED_LOCK)) == 0) { switch (IoErr()) { case ERROR_OBJECT_IN_USE: case ERROR_DISK_NOT_VALIDATED: errno = EBUSY; break; case ERROR_OBJECT_NOT_FOUND: errno = ENOENT; break; default: errno = 0; break; } return -1; } if (!Examine64(lock, &fib, TAG_DONE)) { UnLock(lock); errno = 0; return -1; } UnLock(lock); buffer->st_size = fib.fib_Size64; buffer->st_mode = (fib.fib_DirEntryType > 0 ? S_IFDIR : S_IFREG); timeInterval = 252460800; /* 1978-01-01 */ locale = OpenLocale(NULL); /* * FIXME: This does not take DST into account. But unfortunately, there * is no way to figure out if DST was in effect when the file was * modified. */ timeInterval += locale->loc_GMTOffset * 60.0; CloseLocale(locale); timeInterval += fib.fib_Date.ds_Days * 86400.0; timeInterval += fib.fib_Date.ds_Minute * 60.0; timeInterval += fib.fib_Date.ds_Tick / (of_time_interval_t)TICKS_PER_SECOND; buffer->st_atime = buffer->st_mtime = buffer->st_ctime = timeInterval; return 0; #elif defined(OF_HAVE_OFF64_T) return stat64([path cStringWithEncoding: [OFLocalization encoding]], buffer); #else return stat([path cStringWithEncoding: [OFLocalization encoding]], buffer); #endif } static int of_lstat(OFString *path, of_stat_t *buffer) { #if defined(HAVE_LSTAT) && !defined(OF_WINDOWS) && !defined(OF_MORPHOS) # ifdef OF_HAVE_OFF64_T return lstat64([path cStringWithEncoding: [OFLocalization encoding]], buffer); # else return lstat([path cStringWithEncoding: [OFLocalization encoding]], buffer); # endif #else return of_stat(path, buffer); #endif } static void setTypeAttribute(of_mutable_file_attributes_t attributes, of_stat_t *s) { if (S_ISREG(s->st_mode)) [attributes setObject: of_file_type_regular forKey: of_file_attribute_key_type]; else if (S_ISDIR(s->st_mode)) [attributes setObject: of_file_type_directory forKey: of_file_attribute_key_type]; #ifdef S_ISLNK else if (S_ISLNK(s->st_mode)) [attributes setObject: of_file_type_symbolic_link forKey: of_file_attribute_key_type]; #endif #ifdef S_ISFIFO else if (S_ISFIFO(s->st_mode)) [attributes setObject: of_file_type_fifo forKey: of_file_attribute_key_type]; #endif #ifdef S_ISCHR else if (S_ISCHR(s->st_mode)) [attributes setObject: of_file_type_character_special forKey: of_file_attribute_key_type]; #endif #ifdef S_ISBLK else if (S_ISBLK(s->st_mode)) [attributes setObject: of_file_type_block_special forKey: of_file_attribute_key_type]; #endif #ifdef S_ISSOCK else if (S_ISSOCK(s->st_mode)) [attributes setObject: of_file_type_socket forKey: of_file_attribute_key_type]; #endif } static void setDateAttributes(of_mutable_file_attributes_t attributes, of_stat_t *s) { /* FIXME: We could be more precise on some OSes */ [attributes setObject: [OFDate dateWithTimeIntervalSince1970: s->st_atime] forKey: of_file_attribute_key_last_access_date]; [attributes setObject: [OFDate dateWithTimeIntervalSince1970: s->st_mtime] forKey: of_file_attribute_key_modification_date]; [attributes setObject: [OFDate dateWithTimeIntervalSince1970: s->st_ctime] forKey: of_file_attribute_key_status_change_date]; } static void setOwnerAndGroupAttributes(of_mutable_file_attributes_t attributes, of_stat_t *s) { #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER [attributes setObject: [NSNumber numberWithUInt16: s->st_uid] forKey: of_file_attribute_key_posix_uid]; [attributes setObject: [NSNumber numberWithUInt16: s->st_gid] forKey: of_file_attribute_key_posix_gid]; # ifdef OF_HAVE_THREADS [passwdMutex lock]; @try { # endif of_string_encoding_t encoding = [OFLocalization encoding]; struct passwd *passwd = getpwuid(s->st_uid); struct group *group_ = getgrgid(s->st_gid); if (passwd != NULL) { OFString *owner = [OFString stringWithCString: passwd->pw_name encoding: encoding]; [attributes setObject: owner forKey: of_file_attribute_key_owner]; } if (group_ != NULL) { OFString *group = [OFString stringWithCString: group_->gr_name encoding: encoding]; [attributes setObject: group forKey: of_file_attribute_key_group]; } # ifdef OF_HAVE_THREADS } @finally { [passwdMutex unlock]; } # endif #endif } static void setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes, of_stat_t *s, OFURL *URL) { #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS OFString *path = [URL fileSystemRepresentation]; # ifndef OF_WINDOWS if (S_ISLNK(s->st_mode)) { of_string_encoding_t encoding = [OFLocalization encoding]; char destinationC[PATH_MAX]; ssize_t length; OFString *destination; of_file_attribute_key_t key; length = readlink([path cStringWithEncoding: encoding], destinationC, PATH_MAX); if (length < 0) @throw [OFRetrieveItemAttributesFailedException exceptionWithURL: URL errNo: errno]; destination = [OFString stringWithCString: destinationC encoding: encoding length: length]; key = of_file_attribute_key_symbolic_link_destination; [attributes setObject: destination forKey: key]; } # else WIN32_FIND_DATAW data; if (func_CreateSymbolicLinkW != NULL && FindFirstFileW([path UTF16String], &data) && (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) && data.dwReserved0 == IO_REPARSE_TAG_SYMLINK) { HANDLE handle; OFString *destination; if ((handle = CreateFileW([path UTF16String], 0, (FILE_SHARE_READ | FILE_SHARE_WRITE), NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT, NULL)) == INVALID_HANDLE_VALUE) @throw [OFRetrieveItemAttributesFailedException exceptionWithURL: URL errNo: 0]; @try { union { char bytes[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; REPARSE_DATA_BUFFER data; } buffer; DWORD size; wchar_t *tmp; of_file_attribute_key_t key; if (!DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer.bytes, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &size, NULL)) @throw [OFRetrieveItemAttributesFailedException exceptionWithURL: URL errNo: 0]; if (buffer.data.ReparseTag != IO_REPARSE_TAG_SYMLINK) @throw [OFRetrieveItemAttributesFailedException exceptionWithURL: URL errNo: 0]; # define slrb buffer.data.SymbolicLinkReparseBuffer tmp = slrb.PathBuffer + (slrb.SubstituteNameOffset / sizeof(wchar_t)); destination = [OFString stringWithUTF16String: tmp length: slrb.SubstituteNameLength / sizeof(wchar_t)]; [attributes setObject: of_file_type_symbolic_link forKey: of_file_attribute_key_type]; key = of_file_attribute_key_symbolic_link_destination; [attributes setObject: destination forKey: key]; # undef slrb } @finally { CloseHandle(handle); } } # endif #endif } @implementation OFURLHandler_file + (void)initialize { #ifdef OF_WINDOWS HMODULE module; #endif if (self != [OFURLHandler_file class]) return; /* * Make sure OFFile is initialized. * On some systems, this is needed to initialize the file system driver. */ [OFFile class]; #if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) passwdMutex = [[OFMutex alloc] init]; #endif #if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS) readdirMutex = [[OFMutex alloc] init]; #endif #ifdef OF_WINDOWS if ((module = LoadLibrary("kernel32.dll")) != NULL) func_CreateSymbolicLinkW = (WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR, DWORD)) GetProcAddress(module, "CreateSymbolicLinkW"); #endif } + (bool)of_directoryExistsAtPath: (OFString *)path { of_stat_t s; if (of_stat(path, &s) == -1) return false; return S_ISDIR(s.st_mode); } - (of_file_attributes_t)attributesOfItemAtURL: (OFURL *)URL { of_mutable_file_attributes_t ret = [OFMutableDictionary dictionary]; void *pool = objc_autoreleasePoolPush(); OFString *path; of_stat_t s; if (URL == nil) @throw [OFInvalidArgumentException exception]; if (![[URL scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = [URL fileSystemRepresentation]; if (of_lstat(path, &s) == -1) @throw [OFRetrieveItemAttributesFailedException exceptionWithURL: URL errNo: errno]; if (s.st_size < 0) @throw [OFOutOfRangeException exception]; [ret setObject: [NSNumber numberWithUIntMax: s.st_size] forKey: of_file_attribute_key_size]; setTypeAttribute(ret, &s); [ret setObject: [NSNumber numberWithUInt16: s.st_mode & 07777] forKey: of_file_attribute_key_posix_permissions]; setOwnerAndGroupAttributes(ret, &s); setDateAttributes(ret, &s); setSymbolicLinkDestinationAttribute(ret, &s, URL); objc_autoreleasePoolPop(pool); return ret; } - (void)of_setPOSIXPermissions: (OFNumber *)permissions ofItemAtURL: (OFURL *)URL attributes: (of_file_attributes_t)attributes { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS uint16_t mode = [permissions uInt16Value] & 0777; OFString *path = [URL fileSystemRepresentation]; # ifndef OF_WINDOWS if (chmod([path cStringWithEncoding: [OFLocalization encoding]], mode) != 0) # else if (_wchmod([path UTF16String], mode) != 0) # endif @throw [OFSetItemAttributesFailedException exceptionWithURL: URL attributes: attributes failedAttribute: of_file_attribute_key_posix_permissions errNo: errno]; #else OF_UNRECOGNIZED_SELECTOR #endif } - (void)of_setOwner: (OFString *)owner andGroup: (OFString *)group ofItemAtURL: (OFURL *)URL attributeKey: (of_file_attribute_key_t)attributeKey attributes: (of_file_attributes_t)attributes { #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER OFString *path = [URL fileSystemRepresentation]; uid_t uid = -1; gid_t gid = -1; of_string_encoding_t encoding; if (owner == nil && group == nil) @throw [OFInvalidArgumentException exception]; encoding = [OFLocalization encoding]; # ifdef OF_HAVE_THREADS [passwdMutex lock]; @try { # endif if (owner != nil) { struct passwd *passwd; if ((passwd = getpwnam([owner cStringWithEncoding: encoding])) == NULL) @throw [OFSetItemAttributesFailedException exceptionWithURL: URL attributes: attributes failedAttribute: attributeKey errNo: errno]; uid = passwd->pw_uid; } if (group != nil) { struct group *group_; if ((group_ = getgrnam([group cStringWithEncoding: encoding])) == NULL) @throw [OFSetItemAttributesFailedException exceptionWithURL: URL attributes: attributes failedAttribute: attributeKey errNo: errno]; gid = group_->gr_gid; } # ifdef OF_HAVE_THREADS } @finally { [passwdMutex unlock]; } # endif if (chown([path cStringWithEncoding: encoding], uid, gid) != 0) @throw [OFSetItemAttributesFailedException exceptionWithURL: URL attributes: attributes failedAttribute: attributeKey errNo: errno]; #else OF_UNRECOGNIZED_SELECTOR #endif } - (void)setAttributes: (of_file_attributes_t)attributes ofItemAtURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); OFEnumerator OF_GENERIC(of_file_attribute_key_t) *keyEnumerator; OFEnumerator *objectEnumerator; of_file_attribute_key_t key; id object; if (URL == nil) @throw [OFInvalidArgumentException exception]; if (![[URL scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; keyEnumerator = [attributes keyEnumerator]; objectEnumerator = [attributes objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) { if ([key isEqual: of_file_attribute_key_posix_permissions]) [self of_setPOSIXPermissions: object ofItemAtURL: URL attributes: attributes]; else if ([key isEqual: of_file_attribute_key_owner]) [self of_setOwner: object andGroup: nil ofItemAtURL: URL attributeKey: key attributes: attributes]; else if ([key isEqual: of_file_attribute_key_group]) [self of_setOwner: nil andGroup: object ofItemAtURL: URL attributeKey: key attributes: attributes]; else @throw [OFInvalidArgumentException exception]; } objc_autoreleasePoolPop(pool); } - (bool)fileExistsAtURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); of_stat_t s; bool ret; if (URL == nil) @throw [OFInvalidArgumentException exception]; if (![[URL scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; if (of_stat([URL fileSystemRepresentation], &s) == -1) return false; ret = S_ISREG(s.st_mode); objc_autoreleasePoolPop(pool); return ret; } - (bool)directoryExistsAtURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); of_stat_t s; bool ret; if (URL == nil) @throw [OFInvalidArgumentException exception]; if (![[URL scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; if (of_stat([URL fileSystemRepresentation], &s) == -1) return false; ret = S_ISDIR(s.st_mode); objc_autoreleasePoolPop(pool); return ret; } - (void)createDirectoryAtURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); OFString *path; if (URL == nil) @throw [OFInvalidArgumentException exception]; if (![[URL scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = [URL fileSystemRepresentation]; #if defined(OF_WINDOWS) if (_wmkdir([path UTF16String]) != 0) @throw [OFCreateDirectoryFailedException exceptionWithURL: URL errNo: errno]; #elif defined(OF_MORPHOS) BPTR lock; if ((lock = CreateDir( [path cStringWithEncoding: [OFLocalization encoding]])) == 0) { int errNo; switch (IoErr()) { case ERROR_NO_FREE_STORE: case ERROR_DISK_FULL: errNo = ENOSPC; break; case ERROR_OBJECT_IN_USE: case ERROR_DISK_NOT_VALIDATED: errNo = EBUSY; break; case ERROR_OBJECT_EXISTS: errNo = EEXIST; break; case ERROR_OBJECT_NOT_FOUND: errNo = ENOENT; break; case ERROR_DISK_WRITE_PROTECTED: errNo = EROFS; break; default: errNo = 0; break; } @throw [OFCreateDirectoryFailedException exceptionWithURL: URL errNo: errNo]; } UnLock(lock); #else if (mkdir([path cStringWithEncoding: [OFLocalization encoding]], 0777) != 0) @throw [OFCreateDirectoryFailedException exceptionWithURL: URL errNo: errno]; #endif objc_autoreleasePoolPop(pool); } - (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtURL: (OFURL *)URL { OFMutableArray *files = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); OFString *path; if (URL == nil) @throw [OFInvalidArgumentException exception]; if (![[URL scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = [URL fileSystemRepresentation]; #if defined(OF_WINDOWS) HANDLE handle; WIN32_FIND_DATAW fd; path = [path stringByAppendingString: @"\\*"]; if ((handle = FindFirstFileW([path UTF16String], &fd)) == INVALID_HANDLE_VALUE) { int errNo = 0; if (GetLastError() == ERROR_FILE_NOT_FOUND) errNo = ENOENT; @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil errNo: errNo]; } @try { do { OFString *file; if (!wcscmp(fd.cFileName, L".") || !wcscmp(fd.cFileName, L"..")) continue; file = [OFString stringWithUTF16String: fd.cFileName]; @try { [files addObject: file]; } @finally { [file release]; } } while (FindNextFileW(handle, &fd)); if (GetLastError() != ERROR_NO_MORE_FILES) @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0 errNo: EIO]; } @finally { FindClose(handle); } #elif defined(OF_MORPHOS) of_string_encoding_t encoding = [OFLocalization encoding]; BPTR lock; struct FileInfoBlock fib; if ((lock = Lock([path cStringWithEncoding: encoding], SHARED_LOCK)) == 0) { int errNo; switch (IoErr()) { case ERROR_OBJECT_IN_USE: case ERROR_DISK_NOT_VALIDATED: errNo = EBUSY; break; case ERROR_OBJECT_NOT_FOUND: errNo = ENOENT; break; default: errNo = 0; break; } @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil errNo: errNo]; } @try { if (!Examine(lock, &fib)) @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil errNo: 0]; while (ExNext(lock, &fib)) { OFString *file; file = [[OFString alloc] initWithCString: fib.fib_FileName encoding: encoding]; @try { [files addObject: file]; } @finally { [file release]; } } if (IoErr() != ERROR_NO_MORE_ENTRIES) @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0 errNo: EIO]; } @finally { UnLock(lock); } #else of_string_encoding_t encoding = [OFLocalization encoding]; DIR *dir; if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL) @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil errNo: errno]; # if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS) @try { [readdirMutex lock]; } @catch (id e) { closedir(dir); @throw e; } # endif @try { for (;;) { struct dirent *dirent; # ifdef HAVE_READDIR_R struct dirent buffer; # endif OFString *file; # ifdef HAVE_READDIR_R if (readdir_r(dir, &buffer, &dirent) != 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0 errNo: errno]; if (dirent == NULL) break; # else errno = 0; if ((dirent = readdir(dir)) == NULL) { if (errno == 0) break; else @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0 errNo: errno]; } # endif if (strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name, "..") == 0) continue; file = [[OFString alloc] initWithCString: dirent->d_name encoding: encoding]; @try { [files addObject: file]; } @finally { [file release]; } } } @finally { closedir(dir); # if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS) [readdirMutex unlock]; # endif } #endif [files makeImmutable]; objc_autoreleasePoolPop(pool); return files; } - (void)removeItemAtURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); OFString *path; of_stat_t s; if (URL == nil) @throw [OFInvalidArgumentException exception]; if (![[URL scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = [URL fileSystemRepresentation]; if (of_lstat(path, &s) != 0) @throw [OFRemoveItemFailedException exceptionWithURL: URL errNo: errno]; if (S_ISDIR(s.st_mode)) { OFArray *contents; @try { contents = [self contentsOfDirectoryAtURL: URL]; } @catch (id e) { /* * Only convert exceptions to * OFRemoveItemFailedException that have an errNo * property. This covers all I/O related exceptions * from the operations used to remove an item, all * others should be left as is. */ if ([e respondsToSelector: @selector(errNo)]) @throw [OFRemoveItemFailedException exceptionWithURL: URL errNo: [e errNo]]; @throw e; } for (OFString *item in contents) { void *pool2 = objc_autoreleasePoolPush(); [self removeItemAtURL: [OFURL fileURLWithPath: [path stringByAppendingPathComponent: item]]]; objc_autoreleasePoolPop(pool2); } #ifndef OF_MORPHOS # ifndef OF_WINDOWS if (rmdir([path cStringWithEncoding: [OFLocalization encoding]]) != 0) # else if (_wrmdir([path UTF16String]) != 0) # endif @throw [OFRemoveItemFailedException exceptionWithURL: URL errNo: errno]; } else { # ifndef OF_WINDOWS if (unlink([path cStringWithEncoding: [OFLocalization encoding]]) != 0) # else if (_wunlink([path UTF16String]) != 0) # endif @throw [OFRemoveItemFailedException exceptionWithURL: URL errNo: errno]; #endif } #ifdef OF_MORPHOS if (!DeleteFile( [path cStringWithEncoding: [OFLocalization encoding]])) { int errNo; switch (IoErr()) { case ERROR_OBJECT_IN_USE: case ERROR_DISK_NOT_VALIDATED: errNo = EBUSY; break; case ERROR_OBJECT_NOT_FOUND: errNo = ENOENT; break; case ERROR_DISK_WRITE_PROTECTED: errNo = EROFS; break; case ERROR_DELETE_PROTECTED: errNo = EACCES; break; default: errNo = 0; break; } @throw [OFRemoveItemFailedException exceptionWithURL: URL errNo: errNo]; } #endif objc_autoreleasePoolPop(pool); } #ifdef OF_FILE_MANAGER_SUPPORTS_LINKS - (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination { void *pool = objc_autoreleasePoolPush(); OFString *sourcePath, *destinationPath; if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; if (![[source scheme] isEqual: _scheme] || ![[destination scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; sourcePath = [source fileSystemRepresentation]; destinationPath = [destination fileSystemRepresentation]; # ifndef OF_WINDOWS of_string_encoding_t encoding = [OFLocalization encoding]; if (link([sourcePath cStringWithEncoding: encoding], [destinationPath cStringWithEncoding: encoding]) != 0) @throw [OFLinkFailedException exceptionWithSourceURL: source destinationURL: destination errNo: errno]; # else if (!CreateHardLinkW([destinationPath UTF16String], [sourcePath UTF16String], NULL)) @throw [OFLinkFailedException exceptionWithSourceURL: source destinationURL: destination errNo: 0]; # endif objc_autoreleasePoolPop(pool); } #endif #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS - (void)createSymbolicLinkAtURL: (OFURL *)URL withDestinationPath: (OFString *)target { void *pool = objc_autoreleasePoolPush(); OFString *path; if (URL == nil || target == nil) @throw [OFInvalidArgumentException exception]; if (![[URL scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = [URL fileSystemRepresentation]; # ifndef OF_WINDOWS of_string_encoding_t encoding = [OFLocalization encoding]; if (symlink([target cStringWithEncoding: encoding], [path cStringWithEncoding: encoding]) != 0) @throw [OFCreateSymbolicLinkFailedException exceptionWithURL: URL target: target errNo: errno]; # else if (func_CreateSymbolicLinkW == NULL) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; if (!func_CreateSymbolicLinkW([path UTF16String], [target UTF16String], 0)) @throw [OFCreateSymbolicLinkFailedException exceptionWithURL: URL target: target errNo: 0]; # endif objc_autoreleasePoolPop(pool); } #endif @end |
Modified src/exceptions/OFCreateDirectoryFailedException.h from [f119eab461] to [29b7244a1a].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | * file. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFCreateDirectoryFailedException \ * OFCreateDirectoryFailedException.h \ * ObjFW/OFCreateDirectoryFailedException.h * * @brief An exception indicating a directory couldn't be created. */ @interface OFCreateDirectoryFailedException: OFException { | > > | | | | < | | | < | | | 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 64 65 66 67 68 69 70 71 | * file. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFURL; /*! * @class OFCreateDirectoryFailedException \ * OFCreateDirectoryFailedException.h \ * ObjFW/OFCreateDirectoryFailedException.h * * @brief An exception indicating a directory couldn't be created. */ @interface OFCreateDirectoryFailedException: OFException { OFURL *_URL; int _errNo; } /*! * The URL of the directory which couldn't be created. */ @property (readonly, nonatomic) OFURL *URL; /*! * The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; + (instancetype)exception OF_UNAVAILABLE; /*! * @brief Creates a new, autoreleased create directory failed exception. * * @param URL The URL of the directory which could not be created * @param errNo The errno of the error that occurred * @return A new, autoreleased create directory failed exception */ + (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated create directory failed exception. * * @param URL The URL of the directory which could not be created * @param errNo The errno of the error that occurred * @return An initialized create directory failed exception */ - (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFCreateDirectoryFailedException.m from [ef4b8f855c] to [66c2ef82c5].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 | * file. */ #include "config.h" #import "OFCreateDirectoryFailedException.h" #import "OFString.h" @implementation OFCreateDirectoryFailedException | > | | | | | | | | | < | 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 64 65 66 67 68 69 70 71 | * file. */ #include "config.h" #import "OFCreateDirectoryFailedException.h" #import "OFString.h" #import "OFURL.h" @implementation OFCreateDirectoryFailedException @synthesize URL = _URL, errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo { return [[[self alloc] initWithURL: URL errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo { self = [super init]; @try { _URL = [URL copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_URL release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to create directory %@: %@", _URL, of_strerror(_errNo)]; } @end |
Modified src/exceptions/OFCreateSymbolicLinkFailedException.h from [5b6994b167] to [f58161cb91].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | * file. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFCreateSymbolicLinkFailedException \ * OFCreateSymbolicLinkFailedException.h \ * ObjFW/OFCreateSymbolicLinkFailedException.h * * @brief An exception indicating that creating a symbolic link failed. */ @interface OFCreateSymbolicLinkFailedException: OFException { | > > > | | | | | | | | | | | | | | | | 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | * file. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFURL; /*! * @class OFCreateSymbolicLinkFailedException \ * OFCreateSymbolicLinkFailedException.h \ * ObjFW/OFCreateSymbolicLinkFailedException.h * * @brief An exception indicating that creating a symbolic link failed. */ @interface OFCreateSymbolicLinkFailedException: OFException { OFURL *_URL; OFString *_target; int _errNo; } /*! * The URL at which the symlink should have been created. */ @property (readonly, nonatomic) OFURL *URL; /*! * The target for the symlink. */ @property (readonly, nonatomic) OFString *target; /*! * The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; + (instancetype)exception OF_UNAVAILABLE; /*! * @brief Creates a new, autoreleased create symbolic link failed exception. * * @param URL The URL where the symlink should have been created * @param target The target for the symbolic link * @param errNo The errno of the error that occurred * @return A new, autoreleased create symbolic link failed exception */ + (instancetype)exceptionWithURL: (OFURL *)URL target: (OFString *)target errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated create symbolic link failed * exception. * * @param URL The URL where the symlink should have been created * @param target The target for the symbolic link * @param errNo The errno of the error that occurred * @return An initialized create symbolic link failed exception */ - (instancetype)initWithURL: (OFURL *)URL target: (OFString *)target errNo: (int)errNo OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFCreateSymbolicLinkFailedException.m from [650806d944] to [797bac35d2].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 | * file. */ #include "config.h" #import "OFCreateSymbolicLinkFailedException.h" #import "OFString.h" @implementation OFCreateSymbolicLinkFailedException | > < | | | | | | | | | | | | | | | | | 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | * file. */ #include "config.h" #import "OFCreateSymbolicLinkFailedException.h" #import "OFString.h" #import "OFURL.h" @implementation OFCreateSymbolicLinkFailedException @synthesize URL = _URL, target = _target, errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithURL: (OFURL *)URL target: (OFString *)target errNo: (int)errNo { return [[[self alloc] initWithURL: URL target: target errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithURL: (OFURL *)URL target: (OFString *)target errNo: (int)errNo { self = [super init]; @try { _URL = [URL copy]; _target = [target copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_URL release]; [_target release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to create symbolic link %@ with target %@: %@", _URL, _target, of_strerror(_errNo)]; } @end |
Modified src/exceptions/OFLinkFailedException.h from [a01a95a159] to [c60fe0b102].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFLinkFailedException \ * OFLinkFailedException.h ObjFW/OFLinkFailedException.h * * @brief An exception indicating that creating a link failed. */ @interface OFLinkFailedException: OFException { | > > | | | | | | | | | | | | | | | | 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | * 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; } /*! * A URL with the source for the link. */ @property (readonly, nonatomic) OFURL *sourceURL; /*! * A URL with the destination for the link. */ @property (readonly, nonatomic) OFURL *destinationURL; /*! * The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; + (instancetype)exception OF_UNAVAILABLE; /*! * @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)init 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; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFLinkFailedException.m from [569378f421] to [420629fe36].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 | * file. */ #include "config.h" #import "OFLinkFailedException.h" #import "OFString.h" @implementation OFLinkFailedException | > | | | | | | | | | | | | | | | | 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | * 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, of_strerror(_errNo)]; } @end |
Modified src/exceptions/OFOpenItemFailedException.h from [8cc711f5f5] to [fa09fcf95b].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFOpenItemFailedException \ * OFOpenItemFailedException.h ObjFW/OFOpenItemFailedException.h * * @brief An exception indicating an item could not be opened. */ @interface OFOpenItemFailedException: OFException { | > > > > | > > > > > | > > > > > > > > | > > > > > > > > > > > > > > > > | | | 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 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 | * file. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFURL; /*! * @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; } /*! * The URL of the item which could not be opened. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFURL *URL; /*! * The path of the item which could not be opened. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *path; /*! * The mode in which the item should have been opened. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *mode; /*! * The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; + (instancetype)exception OF_UNAVAILABLE; /*! * @brief Creates a new, autoreleased 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 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)init 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; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFOpenItemFailedException.m from [0b9774a53f] to [20bf42ce40].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 | * file. */ #include "config.h" #import "OFOpenItemFailedException.h" #import "OFString.h" @implementation OFOpenItemFailedException | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > | | | 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 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 116 | * file. */ #include "config.h" #import "OFOpenItemFailedException.h" #import "OFString.h" #import "OFURL.h" @implementation OFOpenItemFailedException @synthesize URL = _URL, path = _path, mode = _mode, errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (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)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithURL: (OFURL *)URL mode: (OFString *)mode errNo: (int)errNo { self = [super init]; @try { _URL = [URL copy]; _mode = [mode copy]; _errNo = errNo; } @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; } - (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, of_strerror(_errNo)]; else return [OFString stringWithFormat: @"Failed to open item %@: %@", item, of_strerror(_errNo)]; } @end |
Modified src/exceptions/OFRemoveItemFailedException.h from [f135f025df] to [672847c26c].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFRemoveItemFailedException \ * OFRemoveItemFailedException.h ObjFW/OFRemoveItemFailedException.h * * @brief An exception indicating that removing an item failed. */ @interface OFRemoveItemFailedException: OFException { | > > | | | | | | | | | | 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 64 65 66 67 68 69 70 | * file. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFURL; /*! * @class OFRemoveItemFailedException \ * OFRemoveItemFailedException.h ObjFW/OFRemoveItemFailedException.h * * @brief An exception indicating that removing an item failed. */ @interface OFRemoveItemFailedException: OFException { OFURL *_URL; int _errNo; } /*! * The URL of the item which could not be removed. */ @property (readonly, nonatomic) OFURL *URL; /*! * The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; + (instancetype)exception OF_UNAVAILABLE; /*! * @brief Creates a new, autoreleased remove failed exception. * * @param URL The URL of the item which could not be removed * @param errNo The errno of the error that occurred * @return A new, autoreleased remove item failed exception */ + (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated remove failed exception. * * @param URL The URL of the item which could not be removed * @param errNo The errno of the error that occurred * @return An initialized remove item failed exception */ - (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFRemoveItemFailedException.m from [44c7b9e59e] to [7123053eac].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 | * file. */ #include "config.h" #import "OFRemoveItemFailedException.h" #import "OFString.h" @implementation OFRemoveItemFailedException | > | | | | | | | | | | < | 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 64 65 66 67 68 69 70 71 | * file. */ #include "config.h" #import "OFRemoveItemFailedException.h" #import "OFString.h" #import "OFURL.h" @implementation OFRemoveItemFailedException @synthesize URL = _URL, errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo { return [[[self alloc] initWithURL: URL errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo { self = [super init]; @try { _URL = [URL copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_URL release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to remove item at URL %@: %@", _URL, of_strerror(_errNo)]; } @end |
Modified src/exceptions/OFRetrieveItemAttributesFailedException.h from [b436ab4451] to [9d06732d54].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | * file. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFRetrieveItemAttributesFailedException \ * OFRetrieveItemAttributesFailedException.h \ * ObjFW/OFRetrieveItemAttributesFailedException.h * * @brief An exception indicating an item's attributes could not be retrieved. */ @interface OFRetrieveItemAttributesFailedException: OFException { | > > | | | | < | | | < | | | 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 64 65 66 67 68 69 70 71 72 | * file. */ #import "OFException.h" OF_ASSUME_NONNULL_BEGIN @class OFURL; /*! * @class OFRetrieveItemAttributesFailedException \ * OFRetrieveItemAttributesFailedException.h \ * ObjFW/OFRetrieveItemAttributesFailedException.h * * @brief An exception indicating an item's attributes could not be retrieved. */ @interface OFRetrieveItemAttributesFailedException: OFException { OFURL *_URL; int _errNo; } /*! * The URL of the item whose attributes could not be retrieved. */ @property (readonly, nonatomic) OFURL *URL; /*! * The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; + (instancetype)exception OF_UNAVAILABLE; /*! * @brief Creates a new, autoreleased retrieve item attributes failed exception. * * @param URL The URL of the item whose attributes could not be retrieved * @param errNo The errno of the error that occurred * @return A new, autoreleased retrieve item attributes failed exception */ + (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated retrieve item attributes failed * exception. * * @param URL The URL of the item whose attributes could not be retrieved * @param errNo The errno of the error that occurred * @return An initialized retrieve item attributes failed exception */ - (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFRetrieveItemAttributesFailedException.m from [a424242675] to [791ed1a9c3].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 | * file. */ #include "config.h" #import "OFRetrieveItemAttributesFailedException.h" #import "OFString.h" @implementation OFRetrieveItemAttributesFailedException | > | | | | | | | | | | | 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 64 65 66 67 68 69 70 71 72 | * file. */ #include "config.h" #import "OFRetrieveItemAttributesFailedException.h" #import "OFString.h" #import "OFURL.h" @implementation OFRetrieveItemAttributesFailedException @synthesize URL = _URL, errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithURL: (OFURL *)URL errNo: (int)errNo { return [[[self alloc] initWithURL: URL errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithURL: (OFURL *)URL errNo: (int)errNo { self = [super init]; @try { _URL = [URL copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_URL release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to retrieve attributes for item %@: %@", _URL, of_strerror(_errNo)]; } @end |
Modified src/exceptions/OFSetItemAttributesFailedException.h from [174d24e615] to [c105a3fef7].
︙ | ︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | */ #import "OFException.h" #import "OFFileManager.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFSetItemAttributesFailedException \ * OFSetItemAttributesFailedException.h \ * ObjFW/OFSetItemAttributesFailedException.h * * @brief An exception indicating an item's attributes could not be set. */ @interface OFSetItemAttributesFailedException: OFException { | > > | | | | 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 | */ #import "OFException.h" #import "OFFileManager.h" OF_ASSUME_NONNULL_BEGIN @class OFURL; /*! * @class OFSetItemAttributesFailedException \ * OFSetItemAttributesFailedException.h \ * ObjFW/OFSetItemAttributesFailedException.h * * @brief An exception indicating an item's attributes could not be set. */ @interface OFSetItemAttributesFailedException: OFException { OFURL *_URL; of_file_attributes_t _attributes; of_file_attribute_key_t _failedAttribute; int _errNo; } /*! * The URL of the item whose attributes could not be set. */ @property (readonly, nonatomic) OFURL *URL; /*! * The errno of the error that occurred. */ @property (readonly, nonatomic) int errNo; /*! |
︙ | ︙ | |||
55 56 57 58 59 60 61 | @property (readonly, nonatomic) of_file_attribute_key_t failedAttribute; + (instancetype)exception OF_UNAVAILABLE; /*! * @brief Creates a new, autoreleased set item attributes failed exception. * | | < | | | | | < | | | | | 57 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 | @property (readonly, nonatomic) of_file_attribute_key_t failedAttribute; + (instancetype)exception OF_UNAVAILABLE; /*! * @brief Creates a new, autoreleased set item attributes failed exception. * * @param URL The URL of the item whose attributes could not be set * @param attributes The attributes that should have been set for the specified * item. * @param failedAttribute The first attribute that could not be set * @param errNo The errno of the error that occurred * @return A new, autoreleased set item attributes failed exception */ + (instancetype)exceptionWithURL: (OFURL *)URL attributes: (of_file_attributes_t)attributes failedAttribute: (of_file_attribute_key_t)failedAttribute errNo: (int)errNo; - (instancetype)init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated set item attributes failed exception. * * @param URL The URL of the item whose attributes could not be set * @param attributes The attributes that should have been set for the specified * item. * @param failedAttribute The first attribute that could not be set * @param errNo The errno of the error that occurred * @return An initialized set item attributes failed exception */ - (instancetype)initWithURL: (OFURL *)URL attributes: (of_file_attributes_t)attributes failedAttribute: (of_file_attribute_key_t)failedAttribute errNo: (int)errNo OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified src/exceptions/OFSetItemAttributesFailedException.m from [e8274356e5] to [0ab1afcc6d].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 | * file. */ #include "config.h" #import "OFSetItemAttributesFailedException.h" #import "OFString.h" @implementation OFSetItemAttributesFailedException | > | | | | | | | | | | | | | | | | | 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | * file. */ #include "config.h" #import "OFSetItemAttributesFailedException.h" #import "OFString.h" #import "OFURL.h" @implementation OFSetItemAttributesFailedException @synthesize URL = _URL, attributes = _attributes; @synthesize failedAttribute = _failedAttribute, errNo = _errNo; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithURL: (OFURL *)URL attributes: (of_file_attributes_t)attributes failedAttribute: (of_file_attribute_key_t)failedAttribute errNo: (int)errNo { return [[[self alloc] initWithURL: URL attributes: attributes failedAttribute: failedAttribute errNo: errNo] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithURL: (OFURL *)URL attributes: (of_file_attributes_t)attributes failedAttribute: (of_file_attribute_key_t)failedAttribute errNo: (int)errNo { self = [super init]; @try { _URL = [URL copy]; _attributes = [attributes copy]; _failedAttribute = [failedAttribute copy]; _errNo = errNo; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_URL release]; [_attributes release]; [_failedAttribute release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"Failed to set attribute %@ for item %@: %@", _failedAttribute, _URL, of_strerror(_errNo)]; } @end |
Modified utils/ofzip/OFZIP.m from [5c7f256715] to [b7ac34eb59].
︙ | ︙ | |||
18 19 20 21 22 23 24 25 | #include <string.h> #import "OFApplication.h" #import "OFArray.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFOptionsParser.h" | > | | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include <string.h> #import "OFApplication.h" #import "OFArray.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFLocalization.h" #import "OFOptionsParser.h" #import "OFSandbox.h" #import "OFStdIOStream.h" #import "OFURL.h" #import "OFZIP.h" #import "GZIPArchive.h" #import "TarArchive.h" #import "ZIPArchive.h" #import "OFCreateDirectoryFailedException.h" |
︙ | ︙ | |||
314 315 316 317 318 319 320 | OFString *error = [OFString stringWithCString: strerror([e errNo]) encoding: [OFLocalization encoding]]; [of_stderr writeString: @"\r"]; [of_stderr writeLine: OF_LOCALIZED( @"failed_to_create_directory", @"Failed to create directory %[dir]: %[error]", | | | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | OFString *error = [OFString stringWithCString: strerror([e errNo]) encoding: [OFLocalization encoding]]; [of_stderr writeString: @"\r"]; [of_stderr writeLine: OF_LOCALIZED( @"failed_to_create_directory", @"Failed to create directory %[dir]: %[error]", @"dir", [[e URL] fileSystemRepresentation], @"error", error)]; _exitStatus = 1; } @catch (OFOpenItemFailedException *e) { OFString *error = [OFString stringWithCString: strerror([e errNo]) encoding: [OFLocalization encoding]]; [of_stderr writeString: @"\r"]; |
︙ | ︙ |