Differences From Artifact [57ac566b12]:
- File
src/OFURLHandler_file.m
— part of check-in
[c52f38388c]
at
2019-04-11 00:34:43
on branch trunk
— Make OFFileManager available with --disable-files
As OFFileManager also works with remote URLs, it makes sense to also
make it available when local files are disabled. In this case, all
path-based methods are unavailable. (user: js, size: 31203) [annotate] [blame] [check-ins using]
To Artifact [35b39e789f]:
- File
src/OFURLHandler_file.m
— part of check-in
[2339bc3407]
at
2019-04-15 21:10:33
on branch trunk
— Use GetFileAttributesExW() instead of _wstat64()
Unlike _wstat64(), GetFileAttributesExW() works on drives. (user: js, size: 32344) [annotate] [blame] [check-ins using]
︙ | |||
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 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 | + - + - - - + + + + + + - - + + + | #import "OFRetrieveItemAttributesFailedException.h" #import "OFSetItemAttributesFailedException.h" #ifdef OF_WINDOWS # include <windows.h> # include <direct.h> # include <ntdef.h> # include <wchar.h> #endif #ifdef OF_AMIGAOS # ifdef OF_AMIGAOS4 # define __USE_INLINE__ # define __NOLIBBASE__ # define __NOGLOBALIFACE__ # endif # include <proto/exec.h> # include <proto/dos.h> # include <proto/locale.h> # ifdef OF_AMIGAOS4 # define DeleteFile(path) Delete(path) # endif #endif |
︙ | |||
129 130 131 132 133 134 135 136 137 138 139 140 | 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | if (IDOS != NULL) DropInterface(IDOS); if (DOSBase != NULL) CloseLibrary(DOSBase); } #endif #ifdef OF_WINDOWS static of_time_interval_t filetimeToTimeInterval(const FILETIME *filetime) { return (double)((int64_t)filetime->dwHighDateTime << 32 | filetime->dwLowDateTime) / 10000000.0 - 11644473600.0; } static void setErrno(void) { switch (GetLastError()) { case ERROR_FILE_NOT_FOUND: case ERROR_PATH_NOT_FOUND: case ERROR_NO_MORE_FILES: errno = ENOENT; return; case ERROR_ACCESS_DENIED: errno = EACCES; return; case ERROR_DIRECTORY: errno = ENOTDIR; return; case ERROR_NOT_READY: errno = EBUSY; return; } errno = 0; } #endif static int of_stat(OFString *path, of_stat_t *buffer) { #if defined(OF_WINDOWS) WIN32_FILE_ATTRIBUTE_DATA data; if (!GetFileAttributesExW(path.UTF16String, GetFileExInfoStandard, &data)) { setErrno(); return -1; } buffer->st_size = (uint64_t)data.nFileSizeHigh << 32 | data.nFileSizeLow; if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) buffer->st_mode = S_IFDIR; else if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { WIN32_FIND_DATAW findData; HANDLE findHandle; if ((findHandle = FindFirstFileW(path.UTF16String, &findData)) == INVALID_HANDLE_VALUE) { setErrno(); return -1; } @try { if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) { /* Race? Indicate to try again. */ errno = EAGAIN; return -1; } buffer->st_mode = (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK ? S_IFLNK : S_IFREG); } @finally { FindClose(findHandle); } } else buffer->st_mode = S_IFREG; buffer->st_mode |= (data.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? (S_IRUSR | S_IXUSR) : (S_IRUSR | S_IWUSR | S_IXUSR)); buffer->st_atime = filetimeToTimeInterval(&data.ftLastAccessTime); buffer->st_mtime = filetimeToTimeInterval(&data.ftLastWriteTime); buffer->st_ctime = buffer->st_birthtime = filetimeToTimeInterval(&data.ftCreationTime); buffer->fileAttributes = data.dwFileAttributes; |
︙ | |||
290 291 292 293 294 295 296 297 298 299 300 301 302 303 | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | + + + + + | 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]; #ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME [attributes setObject: [OFDate dateWithTimeIntervalSince1970: s->st_birthtime] forKey: of_file_attribute_key_creation_date]; #endif } static void setOwnerAndGroupAttributes(of_mutable_file_attributes_t attributes, of_stat_t *s) { #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER |
︙ | |||
335 336 337 338 339 340 341 342 343 | 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 | + - + - - - - - - + - - - - - - - - - - - - - - - - - + - + - - - + + | } @finally { [passwdMutex unlock]; } # endif #endif } #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS static void setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes, |
︙ | |||
435 436 437 438 439 440 441 | 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | - + - + | [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 { |
︙ | |||
494 495 496 497 498 499 500 | 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | - - - - - - - - | * On some systems, this is needed to initialize the file system driver. */ [OFFile class]; } + (bool)of_directoryExistsAtPath: (OFString *)path { |
︙ | |||
556 557 558 559 560 561 562 | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | + + - + + | setTypeAttribute(ret, &s); [ret setObject: [NSNumber numberWithUInt16: s.st_mode & 07777] forKey: of_file_attribute_key_posix_permissions]; setOwnerAndGroupAttributes(ret, &s); setDateAttributes(ret, &s); #ifdef S_ISLNK if (S_ISLNK(s.st_mode)) |
︙ | |||
699 700 701 702 703 704 705 | 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 | - - - - - - - - - - - - - - - - - - - - - - | objc_autoreleasePoolPop(pool); } - (bool)fileExistsAtURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); |
︙ |