Differences From Artifact [78d1e3fb39]:
- File
src/OFURLHandler_file.m
— part of check-in
[b31bd48f90]
at
2018-05-26 14:49:26
on branch trunk
— Remove #define INTUITION_CLASSES_H hack
This has been fixed upstream in amiga-gcc. (user: js, size: 28032) [annotate] [blame] [check-ins using]
To Artifact [74393b965f]:
- File src/OFURLHandler_file.m — part of check-in [aa0384d1bf] at 2018-07-28 18:45:36 on branch trunk — Rename OFLocalization -> OFLocale (user: js, size: 27864) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
35 36 37 38 39 40 41 | # include <grp.h> #endif #import "OFURLHandler_file.h" #import "OFArray.h" #import "OFDate.h" #import "OFFile.h" | | | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | # include <grp.h> #endif #import "OFURLHandler_file.h" #import "OFArray.h" #import "OFDate.h" #import "OFFile.h" #import "OFLocale.h" #import "OFNumber.h" #import "OFURL.h" #ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif |
︙ | ︙ | |||
107 108 109 110 111 112 113 | return _wstat64([path UTF16String], buffer); #elif defined(OF_AMIGAOS) BPTR lock; struct FileInfoBlock fib; of_time_interval_t timeInterval; struct Locale *locale; | | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | return _wstat64([path UTF16String], buffer); #elif defined(OF_AMIGAOS) BPTR lock; struct FileInfoBlock fib; of_time_interval_t timeInterval; struct Locale *locale; if ((lock = Lock([path cStringWithEncoding: [OFLocale encoding]], SHARED_LOCK)) == 0) { switch (IoErr()) { case ERROR_OBJECT_IN_USE: case ERROR_DISK_NOT_VALIDATED: errno = EBUSY; break; case ERROR_OBJECT_NOT_FOUND: |
︙ | ︙ | |||
165 166 167 168 169 170 171 | 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) | | < | < | < | < | 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 | 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: [OFLocale encoding]], buffer); #else return stat([path cStringWithEncoding: [OFLocale encoding]], buffer); #endif } static int of_lstat(OFString *path, of_stat_t *buffer) { #if defined(HAVE_LSTAT) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS) # ifdef OF_HAVE_OFF64_T return lstat64([path cStringWithEncoding: [OFLocale encoding]], buffer); # else return lstat([path cStringWithEncoding: [OFLocale encoding]], buffer); # endif #else return of_stat(path, buffer); #endif } static void |
︙ | ︙ | |||
254 255 256 257 258 259 260 | [attributes setObject: [NSNumber numberWithUInt16: s->st_gid] forKey: of_file_attribute_key_posix_gid]; # ifdef OF_HAVE_THREADS [passwdMutex lock]; @try { # endif | | | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | [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 = [OFLocale 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]; |
︙ | ︙ | |||
292 293 294 295 296 297 298 | 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)) { | | | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | 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 = [OFLocale encoding]; char destinationC[PATH_MAX]; ssize_t length; OFString *destination; of_file_attribute_key_t key; length = readlink([path cStringWithEncoding: encoding], destinationC, PATH_MAX); |
︙ | ︙ | |||
479 480 481 482 483 484 485 | 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 | | < | 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | 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: [OFLocale encoding]], mode) != 0) # else if (_wchmod([path UTF16String], mode) != 0) # endif @throw [OFSetItemAttributesFailedException exceptionWithURL: URL attributes: attributes failedAttribute: of_file_attribute_key_posix_permissions |
︙ | ︙ | |||
509 510 511 512 513 514 515 | uid_t uid = -1; gid_t gid = -1; of_string_encoding_t encoding; if (owner == nil && group == nil) @throw [OFInvalidArgumentException exception]; | | | 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | uid_t uid = -1; gid_t gid = -1; of_string_encoding_t encoding; if (owner == nil && group == nil) @throw [OFInvalidArgumentException exception]; encoding = [OFLocale encoding]; # ifdef OF_HAVE_THREADS [passwdMutex lock]; @try { # endif if (owner != nil) { struct passwd *passwd; |
︙ | ︙ | |||
668 669 670 671 672 673 674 | @throw [OFCreateDirectoryFailedException exceptionWithURL: URL errNo: errno]; #elif defined(OF_AMIGAOS) BPTR lock; if ((lock = CreateDir( | | | 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 | @throw [OFCreateDirectoryFailedException exceptionWithURL: URL errNo: errno]; #elif defined(OF_AMIGAOS) BPTR lock; if ((lock = CreateDir( [path cStringWithEncoding: [OFLocale encoding]])) == 0) { int errNo; switch (IoErr()) { case ERROR_NO_FREE_STORE: case ERROR_DISK_FULL: errNo = ENOSPC; break; |
︙ | ︙ | |||
701 702 703 704 705 706 707 | @throw [OFCreateDirectoryFailedException exceptionWithURL: URL errNo: errNo]; } UnLock(lock); #else | | < | 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | @throw [OFCreateDirectoryFailedException exceptionWithURL: URL errNo: errNo]; } UnLock(lock); #else if (mkdir([path cStringWithEncoding: [OFLocale encoding]], 0777) != 0) @throw [OFCreateDirectoryFailedException exceptionWithURL: URL errNo: errno]; #endif objc_autoreleasePoolPop(pool); } |
︙ | ︙ | |||
767 768 769 770 771 772 773 | @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0 errNo: EIO]; } @finally { FindClose(handle); } #elif defined(OF_AMIGAOS) | | | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 | @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0 errNo: EIO]; } @finally { FindClose(handle); } #elif defined(OF_AMIGAOS) of_string_encoding_t encoding = [OFLocale encoding]; BPTR lock; struct FileInfoBlock fib; if ((lock = Lock([path cStringWithEncoding: encoding], SHARED_LOCK)) == 0) { int errNo; |
︙ | ︙ | |||
822 823 824 825 826 827 828 | exceptionWithObject: self requestedLength: 0 errNo: EIO]; } @finally { UnLock(lock); } #else | | | 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | exceptionWithObject: self requestedLength: 0 errNo: EIO]; } @finally { UnLock(lock); } #else of_string_encoding_t encoding = [OFLocale encoding]; DIR *dir; if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL) @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil errNo: errno]; |
︙ | ︙ | |||
946 947 948 949 950 951 952 | [path stringByAppendingPathComponent: item]]]; objc_autoreleasePoolPop(pool2); } #ifndef OF_AMIGAOS # ifndef OF_WINDOWS | | < | | < | 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 | [path stringByAppendingPathComponent: item]]]; objc_autoreleasePoolPop(pool2); } #ifndef OF_AMIGAOS # ifndef OF_WINDOWS if (rmdir([path cStringWithEncoding: [OFLocale encoding]]) != 0) # else if (_wrmdir([path UTF16String]) != 0) # endif @throw [OFRemoveItemFailedException exceptionWithURL: URL errNo: errno]; } else { # ifndef OF_WINDOWS if (unlink([path cStringWithEncoding: [OFLocale encoding]]) != 0) # else if (_wunlink([path UTF16String]) != 0) # endif @throw [OFRemoveItemFailedException exceptionWithURL: URL errNo: errno]; #endif } #ifdef OF_AMIGAOS if (!DeleteFile([path cStringWithEncoding: [OFLocale encoding]])) { int errNo; switch (IoErr()) { case ERROR_OBJECT_IN_USE: case ERROR_DISK_NOT_VALIDATED: errNo = EBUSY; break; |
︙ | ︙ | |||
1017 1018 1019 1020 1021 1022 1023 | ![[destination scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; sourcePath = [source fileSystemRepresentation]; destinationPath = [destination fileSystemRepresentation]; # ifndef OF_WINDOWS | | | 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 | ![[destination scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; sourcePath = [source fileSystemRepresentation]; destinationPath = [destination fileSystemRepresentation]; # ifndef OF_WINDOWS of_string_encoding_t encoding = [OFLocale encoding]; if (link([sourcePath cStringWithEncoding: encoding], [destinationPath cStringWithEncoding: encoding]) != 0) @throw [OFLinkFailedException exceptionWithSourceURL: source destinationURL: destination errNo: errno]; |
︙ | ︙ | |||
1054 1055 1056 1057 1058 1059 1060 | if (![[URL scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = [URL fileSystemRepresentation]; # ifndef OF_WINDOWS | | | 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 | if (![[URL scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = [URL fileSystemRepresentation]; # ifndef OF_WINDOWS of_string_encoding_t encoding = [OFLocale encoding]; if (symlink([target cStringWithEncoding: encoding], [path cStringWithEncoding: encoding]) != 0) @throw [OFCreateSymbolicLinkFailedException exceptionWithURL: URL target: target errNo: errno]; |
︙ | ︙ | |||
1104 1105 1106 1107 1108 1109 1110 | if (_wrename([[source fileSystemRepresentation] UTF16String], [[destination fileSystemRepresentation] UTF16String]) != 0) @throw [OFMoveItemFailedException exceptionWithSourceURL: source destinationURL: destination errNo: errno]; #elif defined(OF_AMIGAOS) | | | 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 | if (_wrename([[source fileSystemRepresentation] UTF16String], [[destination fileSystemRepresentation] UTF16String]) != 0) @throw [OFMoveItemFailedException exceptionWithSourceURL: source destinationURL: destination errNo: errno]; #elif defined(OF_AMIGAOS) of_string_encoding_t encoding = [OFLocale encoding]; if (!Rename([[source fileSystemRepresentation] cStringWithEncoding: encoding], [[destination fileSystemRepresentation] cStringWithEncoding: encoding])) { int errNo; |
︙ | ︙ | |||
1140 1141 1142 1143 1144 1145 1146 | @throw [OFMoveItemFailedException exceptionWithSourceURL: source destinationURL: destination errNo: errNo]; } #else | | | 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 | @throw [OFMoveItemFailedException exceptionWithSourceURL: source destinationURL: destination errNo: errNo]; } #else of_string_encoding_t encoding = [OFLocale encoding]; if (rename([[source fileSystemRepresentation] cStringWithEncoding: encoding], [[destination fileSystemRepresentation] cStringWithEncoding: encoding]) != 0) @throw [OFMoveItemFailedException exceptionWithSourceURL: source |
︙ | ︙ |