Differences From Artifact [ce2f7bd650]:
- File src/OFFileManager.m — part of check-in [4175b93242] at 2017-06-03 14:37:19 on branch trunk — OFFileManager: Mask modes to ensure safe modes (user: js, size: 25192) [annotate] [blame] [check-ins using]
To Artifact [2b969b9f4d]:
- File
src/OFFileManager.m
— part of check-in
[4f36894ce7]
at
2017-06-05 17:36:28
on branch trunk
— Clean up exceptions a little
This removes several initializers that omitted the errNo. Removing those
forces to think about whether there is a meaningful errNo to set instead
of just omitting it. (user: js, size: 25351) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
321 322 323 324 325 326 327 328 329 330 331 332 333 334 | #ifndef OF_WINDOWS DIR *dir; encoding = [OFLocalization encoding]; if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL) @throw [OFOpenItemFailedException exceptionWithPath: path errNo: errno]; # if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS) [readdirMutex lock]; # endif @try { for (;;) { | > | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | #ifndef OF_WINDOWS DIR *dir; encoding = [OFLocalization encoding]; if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL) @throw [OFOpenItemFailedException exceptionWithPath: path mode: nil errNo: errno]; # if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS) [readdirMutex lock]; # endif @try { for (;;) { |
︙ | ︙ | |||
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 | &fd)) == INVALID_HANDLE_VALUE) { int errNo = 0; if (GetLastError() == ERROR_FILE_NOT_FOUND) errNo = ENOENT; @throw [OFOpenItemFailedException exceptionWithPath: path errNo: errNo]; } @try { do { void *pool2 = objc_autoreleasePoolPush(); OFString *file; if (!wcscmp(fd.cFileName, L".") || !wcscmp(fd.cFileName, L"..")) continue; file = [OFString stringWithUTF16String: fd.cFileName]; [files addObject: file]; objc_autoreleasePoolPop(pool2); } while (FindNextFileW(handle, &fd)); if (GetLastError() != ERROR_NO_MORE_FILES) @throw [OFReadFailedException exceptionWithObject: self | > | > | 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 | &fd)) == INVALID_HANDLE_VALUE) { int errNo = 0; if (GetLastError() == ERROR_FILE_NOT_FOUND) errNo = ENOENT; @throw [OFOpenItemFailedException exceptionWithPath: path mode: nil errNo: errNo]; } @try { do { void *pool2 = objc_autoreleasePoolPush(); OFString *file; if (!wcscmp(fd.cFileName, L".") || !wcscmp(fd.cFileName, L"..")) continue; file = [OFString stringWithUTF16String: fd.cFileName]; [files addObject: file]; objc_autoreleasePoolPop(pool2); } while (FindNextFileW(handle, &fd)); if (GetLastError() != ERROR_NO_MORE_FILES) @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0 errNo: EIO]; } @finally { FindClose(handle); } objc_autoreleasePoolPop(pool); #endif |
︙ | ︙ | |||
938 939 940 941 942 943 944 | pool = objc_autoreleasePoolPush(); if (!CreateHardLinkW([destination UTF16String], [source UTF16String], NULL)) @throw [OFLinkFailedException exceptionWithSourcePath: source | | > | 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 | pool = objc_autoreleasePoolPush(); if (!CreateHardLinkW([destination UTF16String], [source UTF16String], NULL)) @throw [OFLinkFailedException exceptionWithSourcePath: source destinationPath: destination errNo: 0]; objc_autoreleasePoolPop(pool); } #endif #if defined(OF_HAVE_SYMLINK) - (void)createSymbolicLinkAtPath: (OFString *)destination |
︙ | ︙ | |||
985 986 987 988 989 990 991 | pool = objc_autoreleasePoolPush(); if (!func_CreateSymbolicLinkW([destination UTF16String], [source UTF16String], 0)) @throw [OFCreateSymbolicLinkFailedException exceptionWithSourcePath: source | | > | 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 | pool = objc_autoreleasePoolPush(); if (!func_CreateSymbolicLinkW([destination UTF16String], [source UTF16String], 0)) @throw [OFCreateSymbolicLinkFailedException exceptionWithSourcePath: source destinationPath: destination errNo: 0]; objc_autoreleasePoolPop(pool); } #endif #ifdef OF_HAVE_READLINK - (OFString *)destinationOfSymbolicLinkAtPath: (OFString *)path |
︙ | ︙ | |||
1029 1030 1031 1032 1033 1034 1035 | if (path == nil) @throw [OFInvalidArgumentException exception]; if ((handle = CreateFileW([path UTF16String], 0, (FILE_SHARE_READ | FILE_SHARE_WRITE), NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT, NULL)) == INVALID_HANDLE_VALUE) | | > | > | > | 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 1065 1066 1067 1068 1069 | if (path == nil) @throw [OFInvalidArgumentException exception]; 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 [OFStatItemFailedException exceptionWithPath: path errNo: 0]; @try { union { char bytes[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; REPARSE_DATA_BUFFER data; } buffer; DWORD size; wchar_t *tmp; if (!DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer.bytes, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &size, NULL)) @throw [OFStatItemFailedException exceptionWithPath: path errNo: 0]; if (buffer.data.ReparseTag != IO_REPARSE_TAG_SYMLINK) @throw [OFStatItemFailedException exceptionWithPath: path errNo: 0]; #define slrb buffer.data.SymbolicLinkReparseBuffer tmp = slrb.PathBuffer + (slrb.SubstituteNameOffset / sizeof(wchar_t)); return [OFString stringWithUTF16String: tmp |
︙ | ︙ |