@@ -93,15 +93,15 @@ # ifdef OF_WINDOWS # define HAVE_STRUCT_STAT_ST_BIRTHTIME OFTimeInterval st_birthtime; DWORD fileAttributes; # endif -} of_stat_t; +} Stat; #elif defined(HAVE_STAT64) -typedef struct stat64 of_stat_t; +typedef struct stat64 Stat; #else -typedef struct stat of_stat_t; +typedef struct stat Stat; #endif #ifdef OF_WINDOWS # define S_IFLNK 0x10000 # define S_ISLNK(mode) (mode & S_IFLNK) @@ -125,13 +125,13 @@ [readdirMutex release]; } #endif #ifdef OF_WINDOWS -static int (*func__wutime64)(const wchar_t *, struct __utimbuf64 *); -static WINAPI BOOLEAN (*func_CreateSymbolicLinkW)(LPCWSTR, LPCWSTR, DWORD); -static WINAPI BOOLEAN (*func_CreateHardLinkW)(LPCWSTR, LPCWSTR, +static int (*_wutime64FuncPtr)(const wchar_t *, struct __utimbuf64 *); +static WINAPI BOOLEAN (*createSymbolicLinkWFuncPtr)(LPCWSTR, LPCWSTR, DWORD); +static WINAPI BOOLEAN (*createHardLinkWFuncPtr)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES); #endif #ifdef OF_WINDOWS static OFTimeInterval @@ -194,11 +194,11 @@ } } #endif static int -of_stat(OFString *path, of_stat_t *buffer) +statWrapper(OFString *path, Stat *buffer) { #if defined(OF_WINDOWS) WIN32_FILE_ATTRIBUTE_DATA data; bool success; @@ -337,11 +337,11 @@ return 0; #endif } static int -of_lstat(OFString *path, of_stat_t *buffer) +lstatWrapper(OFString *path, Stat *buffer) { #if defined(HAVE_LSTAT) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS) && \ !defined(OF_NINTENDO_3DS) && !defined(OF_WII) # ifdef HAVE_LSTAT64 if (lstat64([path cStringWithEncoding: [OFLocale encoding]], @@ -352,16 +352,16 @@ return errno; # endif return 0; #else - return of_stat(path, buffer); + return statWrapper(path, buffer); #endif } static void -setTypeAttribute(OFMutableFileAttributes attributes, of_stat_t *s) +setTypeAttribute(OFMutableFileAttributes attributes, Stat *s) { if (S_ISREG(s->st_mode)) [attributes setObject: OFFileTypeRegular forKey: OFFileType]; else if (S_ISDIR(s->st_mode)) [attributes setObject: OFFileTypeDirectory forKey: OFFileType]; @@ -389,11 +389,11 @@ [attributes setObject: OFFileTypeSocket forKey: OFFileType]; #endif } static void -setDateAttributes(OFMutableFileAttributes attributes, of_stat_t *s) +setDateAttributes(OFMutableFileAttributes attributes, Stat *s) { /* FIXME: We could be more precise on some OSes */ [attributes setObject: [OFDate dateWithTimeIntervalSince1970: s->st_atime] forKey: OFFileLastAccessDate]; @@ -409,11 +409,11 @@ forKey: OFFileCreationDate]; #endif } static void -setOwnerAndGroupAttributes(OFMutableFileAttributes attributes, of_stat_t *s) +setOwnerAndGroupAttributes(OFMutableFileAttributes attributes, Stat *s) { #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER [attributes setObject: [NSNumber numberWithUnsignedLong: s->st_uid] forKey: OFFileOwnerAccountID]; [attributes setObject: [NSNumber numberWithUnsignedLong: s->st_gid] @@ -480,11 +480,11 @@ forKey: OFFileSymbolicLinkDestination]; # else HANDLE handle; OFString *destination; - if (func_CreateSymbolicLinkW == NULL) + if (createSymbolicLinkWFuncPtr == NULL) 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) @@ -552,18 +552,18 @@ atexit(releaseReaddirMutex); #endif #ifdef OF_WINDOWS if ((module = LoadLibrary("msvcrt.dll")) != NULL) - func__wutime64 = (int (*)(const wchar_t *, + _wutime64FuncPtr = (int (*)(const wchar_t *, struct __utimbuf64 *))GetProcAddress(module, "_wutime64"); if ((module = LoadLibrary("kernel32.dll")) != NULL) { - func_CreateSymbolicLinkW = + createSymbolicLinkWFuncPtr = (WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR, DWORD)) GetProcAddress(module, "CreateSymbolicLinkW"); - func_CreateHardLinkW = + createHardLinkWFuncPtr = (WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES)) GetProcAddress(module, "CreateHardLinkW"); } #endif @@ -575,13 +575,13 @@ [OFFile class]; } + (bool)of_directoryExistsAtPath: (OFString *)path { - of_stat_t s; + Stat s; - if (of_stat(path, &s) != 0) + if (statWrapper(path, &s) != 0) return false; return S_ISDIR(s.st_mode); } @@ -601,21 +601,21 @@ { OFMutableFileAttributes ret = [OFMutableDictionary dictionary]; void *pool = objc_autoreleasePoolPush(); OFString *path; int error; - of_stat_t s; + Stat s; if (URL == nil) @throw [OFInvalidArgumentException exception]; if (![[URL scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = URL.fileSystemRepresentation; - if ((error = of_lstat(path, &s)) != 0) + if ((error = lstatWrapper(path, &s)) != 0) @throw [OFRetrieveItemAttributesFailedException exceptionWithURL: URL errNo: error]; if (s.st_size < 0) @@ -655,19 +655,19 @@ lastAccessDate = modificationDate; if (modificationDate == nil) modificationDate = lastAccessDate; #if defined(OF_WINDOWS) - if (func__wutime64 != NULL) { + if (_wutime64FuncPtr != NULL) { struct __utimbuf64 times = { .actime = (__time64_t)lastAccessDate.timeIntervalSince1970, .modtime = (__time64_t)modificationDate.timeIntervalSince1970 }; - if (func__wutime64([path UTF16String], ×) != 0) + if (_wutime64FuncPtr([path UTF16String], ×) != 0) @throw [OFSetItemAttributesFailedException exceptionWithURL: URL attributes: attributes failedAttribute: attributeKey errNo: errno]; @@ -907,20 +907,20 @@ } - (bool)fileExistsAtURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); - of_stat_t s; + Stat s; bool ret; if (URL == nil) @throw [OFInvalidArgumentException exception]; if (![URL.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; - if (of_stat(URL.fileSystemRepresentation, &s) != 0) { + if (statWrapper(URL.fileSystemRepresentation, &s) != 0) { objc_autoreleasePoolPop(pool); return false; } ret = S_ISREG(s.st_mode); @@ -931,20 +931,20 @@ } - (bool)directoryExistsAtURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); - of_stat_t s; + Stat s; bool ret; if (URL == nil) @throw [OFInvalidArgumentException exception]; if (![URL.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; - if (of_stat(URL.fileSystemRepresentation, &s) != 0) { + if (statWrapper(URL.fileSystemRepresentation, &s) != 0) { objc_autoreleasePoolPop(pool); return false; } ret = S_ISDIR(s.st_mode); @@ -1243,21 +1243,21 @@ - (void)removeItemAtURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); OFString *path; int error; - of_stat_t s; + Stat s; if (URL == nil) @throw [OFInvalidArgumentException exception]; if (![URL.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; path = URL.fileSystemRepresentation; - if ((error = of_lstat(path, &s)) != 0) + if ((error = lstatWrapper(path, &s)) != 0) @throw [OFRemoveItemFailedException exceptionWithURL: URL errNo: error]; if (S_ISDIR(s.st_mode)) { OFArray OF_GENERIC(OFURL *) *contents; @@ -1355,15 +1355,15 @@ @throw [OFLinkFailedException exceptionWithSourceURL: source destinationURL: destination errNo: errno]; # else - if (func_CreateHardLinkW == NULL) + if (createHardLinkWFuncPtr == NULL) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; - if (!func_CreateHardLinkW(destinationPath.UTF16String, + if (!createHardLinkWFuncPtr(destinationPath.UTF16String, sourcePath.UTF16String, NULL)) @throw [OFLinkFailedException exceptionWithSourceURL: source destinationURL: destination errNo: retrieveError()]; @@ -1396,15 +1396,16 @@ @throw [OFCreateSymbolicLinkFailedException exceptionWithURL: URL target: target errNo: errno]; # else - if (func_CreateSymbolicLinkW == NULL) + if (createSymbolicLinkWFuncPtr == NULL) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; - if (!func_CreateSymbolicLinkW(path.UTF16String, target.UTF16String, 0)) + if (!createSymbolicLinkWFuncPtr(path.UTF16String, target.UTF16String, + 0)) @throw [OFCreateSymbolicLinkFailedException exceptionWithURL: URL target: target errNo: retrieveError()]; # endif