@@ -55,20 +55,20 @@ # import "OFMutex.h" #endif #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" +#import "OFGetItemAttributesFailedException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFLinkItemFailedException.h" #import "OFMoveItemFailedException.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 # include @@ -140,11 +140,11 @@ return (double)((int64_t)filetime->dwHighDateTime << 32 | filetime->dwLowDateTime) / 10000000.0 - 11644473600.0; } static int -retrieveError(void) +lastError(void) { switch (GetLastError()) { case ERROR_FILE_NOT_FOUND: case ERROR_PATH_NOT_FOUND: case ERROR_NO_MORE_FILES: @@ -161,11 +161,11 @@ } #endif #ifdef OF_AMIGAOS static int -retrieveError(void) +lastError(void) { switch (IoErr()) { case ERROR_DELETE_PROTECTED: case ERROR_READ_PROTECTED: case ERROR_WRITE_PROTECTED: @@ -209,11 +209,11 @@ success = GetFileAttributesExA( [path cStringWithEncoding: [OFLocale encoding]], GetFileExInfoStandard, &data); if (!success) - return retrieveError(); + return lastError(); buffer->st_size = (uint64_t)data.nFileSizeHigh << 32 | data.nFileSizeLow; if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) @@ -226,11 +226,11 @@ WIN32_FIND_DATAW findData; HANDLE findHandle; if ((findHandle = FindFirstFileW(path.UTF16String, &findData)) == INVALID_HANDLE_VALUE) - return retrieveError(); + return lastError(); @try { if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) /* Race? Indicate to try again. */ @@ -266,20 +266,20 @@ struct Locale *locale; struct DateStamp *date; if ((lock = Lock([path cStringWithEncoding: [OFLocale encoding]], SHARED_LOCK)) == 0) - return retrieveError(); + return lastError(); # if defined(OF_MORPHOS) if (!Examine64(lock, &fib, TAG_DONE)) { # elif defined(OF_AMIGAOS4) if ((ed = ExamineObjectTags(EX_FileLockInput, lock, TAG_END)) == NULL) { # else if (!Examine(lock, &fib)) { # endif - int error = retrieveError(); + int error = lastError(); UnLock(lock); return error; } UnLock(lock); @@ -468,11 +468,11 @@ length = readlink([path cStringWithEncoding: encoding], destinationC, PATH_MAX); if (length < 0) - @throw [OFRetrieveItemAttributesFailedException + @throw [OFGetItemAttributesFailedException exceptionWithURL: URL errNo: errno]; destination = [OFString stringWithCString: destinationC encoding: encoding @@ -488,13 +488,13 @@ return; 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 + @throw [OFGetItemAttributesFailedException exceptionWithURL: URL - errNo: retrieveError()]; + errNo: lastError()]; @try { union { char bytes[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; REPARSE_DATA_BUFFER data; @@ -503,18 +503,18 @@ wchar_t *tmp; if (!DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer.bytes, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &size, NULL)) - @throw [OFRetrieveItemAttributesFailedException + @throw [OFGetItemAttributesFailedException exceptionWithURL: URL - errNo: retrieveError()]; + errNo: lastError()]; if (buffer.data.ReparseTag != IO_REPARSE_TAG_SYMLINK) - @throw [OFRetrieveItemAttributesFailedException + @throw [OFGetItemAttributesFailedException exceptionWithURL: URL - errNo: retrieveError()]; + errNo: lastError()]; # define slrb buffer.data.SymbolicLinkReparseBuffer tmp = slrb.PathBuffer + (slrb.SubstituteNameOffset / sizeof(wchar_t)); @@ -614,11 +614,11 @@ @throw [OFInvalidArgumentException exception]; path = URL.fileSystemRepresentation; if ((error = lstatWrapper(path, &s)) != 0) - @throw [OFRetrieveItemAttributesFailedException + @throw [OFGetItemAttributesFailedException exceptionWithURL: URL errNo: error]; if (s.st_size < 0) @throw [OFOutOfRangeException exception]; @@ -729,11 +729,11 @@ # endif @throw [OFSetItemAttributesFailedException exceptionWithURL: URL attributes: attributes failedAttribute: attributeKey - errNo: retrieveError()]; + errNo: lastError()]; #else OFTimeInterval lastAccessTime = lastAccessDate.timeIntervalSince1970; OFTimeInterval modificationTime = modificationDate.timeIntervalSince1970; struct timeval times[2] = { @@ -987,11 +987,11 @@ if ((lock = CreateDir( [path cStringWithEncoding: [OFLocale encoding]])) == 0) @throw [OFCreateDirectoryFailedException exceptionWithURL: URL - errNo: retrieveError()]; + errNo: lastError()]; UnLock(lock); #else if (mkdir([path cStringWithEncoding: [OFLocale encoding]], 0777) != 0) @throw [OFCreateDirectoryFailedException @@ -1027,11 +1027,11 @@ if ((handle = FindFirstFileW(path.UTF16String, &fd)) == INVALID_HANDLE_VALUE) @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil - errNo: retrieveError()]; + errNo: lastError()]; @try { do { OFString *file; @@ -1051,11 +1051,11 @@ if (GetLastError() != ERROR_NO_MORE_FILES) @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0 - errNo: retrieveError()]; + errNo: lastError()]; } @finally { FindClose(handle); } } else { OFStringEncoding encoding = [OFLocale encoding]; @@ -1065,11 +1065,11 @@ [path cStringWithEncoding: encoding], &fd)) == INVALID_HANDLE_VALUE) @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil - errNo: retrieveError()]; + errNo: lastError()]; @try { do { OFString *file; @@ -1090,11 +1090,11 @@ if (GetLastError() != ERROR_NO_MORE_FILES) @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0 - errNo: retrieveError()]; + errNo: lastError()]; } @finally { FindClose(handle); } } #elif defined(OF_AMIGAOS) @@ -1104,11 +1104,11 @@ if ((lock = Lock([path cStringWithEncoding: encoding], SHARED_LOCK)) == 0) @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil - errNo: retrieveError()]; + errNo: lastError()]; @try { # ifdef OF_AMIGAOS4 struct ExamineData *ed; APTR context; @@ -1117,11 +1117,11 @@ EX_DoCurrentDir, TRUE, EX_DataFields, EXF_NAME, TAG_END)) == NULL) @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil - errNo: retrieveError()]; + errNo: lastError()]; @try { while ((ed = ExamineDir(context)) != NULL) { OFString *file = [[OFString alloc] initWithCString: ed->Name @@ -1142,11 +1142,11 @@ if (!Examine(lock, &fib)) @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil - errNo: retrieveError()]; + errNo: lastError()]; while (ExNext(lock, &fib)) { OFString *file = [[OFString alloc] initWithCString: fib.fib_FileName encoding: encoding]; @@ -1161,11 +1161,11 @@ if (IoErr() != ERROR_NO_MORE_ENTRIES) @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0 - errNo: retrieveError()]; + errNo: lastError()]; } @finally { UnLock(lock); } #else OFStringEncoding encoding = [OFLocale encoding]; @@ -1325,11 +1325,11 @@ #ifdef OF_AMIGAOS if (!DeleteFile([path cStringWithEncoding: [OFLocale encoding]])) @throw [OFRemoveItemFailedException exceptionWithURL: URL - errNo: retrieveError()]; + errNo: lastError()]; #endif objc_autoreleasePoolPop(pool); } @@ -1366,11 +1366,11 @@ if (!createHardLinkWFuncPtr(destinationPath.UTF16String, sourcePath.UTF16String, NULL)) @throw [OFLinkItemFailedException exceptionWithSourceURL: source destinationURL: destination - errNo: retrieveError()]; + errNo: lastError()]; # endif objc_autoreleasePoolPop(pool); } #endif @@ -1407,11 +1407,11 @@ if (!createSymbolicLinkWFuncPtr(path.UTF16String, target.UTF16String, 0)) @throw [OFCreateSymbolicLinkFailedException exceptionWithURL: URL target: target - errNo: retrieveError()]; + errNo: lastError()]; # endif objc_autoreleasePoolPop(pool); } #endif @@ -1440,11 +1440,11 @@ [destination.fileSystemRepresentation cStringWithEncoding: encoding])) @throw [OFMoveItemFailedException exceptionWithSourceURL: source destinationURL: destination - errNo: retrieveError()]; + errNo: lastError()]; #else int status; # ifdef OF_WINDOWS if ([OFSystemInfo isWindowsNT])