@@ -13,10 +13,12 @@ * file. */ #include "config.h" +#define _LARGEFILE64_SOURCE + #include #include #ifdef HAVE_DIRENT_H # include @@ -83,23 +85,23 @@ # endif #endif #if defined(OF_WINDOWS) || defined(OF_AMIGAOS) typedef struct { - of_offset_t st_size; + OFFileOffset st_size; unsigned int st_mode; - of_time_interval_t st_atime, st_mtime, st_ctime; + OFTimeInterval st_atime, st_mtime, st_ctime; # ifdef OF_WINDOWS # define HAVE_STRUCT_STAT_ST_BIRTHTIME - of_time_interval_t 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) @@ -123,18 +125,18 @@ [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 of_time_interval_t +static OFTimeInterval filetimeToTimeInterval(const FILETIME *filetime) { return (double)((int64_t)filetime->dwHighDateTime << 32 | filetime->dwLowDateTime) / 10000000.0 - 11644473600.0; } @@ -192,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; @@ -258,11 +260,11 @@ # ifdef OF_AMIGAOS4 struct ExamineData *ed; # else struct FileInfoBlock fib; # endif - of_time_interval_t timeInterval; + OFTimeInterval timeInterval; struct Locale *locale; struct DateStamp *date; if ((lock = Lock([path cStringWithEncoding: [OFLocale encoding]], SHARED_LOCK)) == 0) @@ -311,11 +313,11 @@ # else date = &fib.fib_Date; # endif timeInterval += date->ds_Days * 86400.0; timeInterval += date->ds_Minute * 60.0; - timeInterval += date->ds_Tick / (of_time_interval_t)TICKS_PER_SECOND; + timeInterval += date->ds_Tick / (OFTimeInterval)TICKS_PER_SECOND; buffer->st_atime = buffer->st_mtime = buffer->st_ctime = timeInterval; # ifdef OF_AMIGAOS4 FreeDosObject(DOS_EXAMINEDATA, ed); @@ -335,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]], @@ -350,104 +352,101 @@ return errno; # endif return 0; #else - return of_stat(path, buffer); + return statWrapper(path, buffer); #endif } static void -setTypeAttribute(of_mutable_file_attributes_t attributes, of_stat_t *s) +setTypeAttribute(OFMutableFileAttributes attributes, Stat *s) { if (S_ISREG(s->st_mode)) - [attributes setObject: of_file_type_regular - forKey: of_file_attribute_key_type]; + [attributes setObject: OFFileTypeRegular forKey: OFFileType]; else if (S_ISDIR(s->st_mode)) - [attributes setObject: of_file_type_directory - forKey: of_file_attribute_key_type]; + [attributes setObject: OFFileTypeDirectory forKey: OFFileType]; #ifdef S_ISLNK else if (S_ISLNK(s->st_mode)) - [attributes setObject: of_file_type_symbolic_link - forKey: of_file_attribute_key_type]; + [attributes setObject: OFFileTypeSymbolicLink + forKey: OFFileType]; #endif #ifdef S_ISFIFO else if (S_ISFIFO(s->st_mode)) - [attributes setObject: of_file_type_fifo - forKey: of_file_attribute_key_type]; + [attributes setObject: OFFileTypeFIFO forKey: OFFileType]; #endif #ifdef S_ISCHR else if (S_ISCHR(s->st_mode)) - [attributes setObject: of_file_type_character_special - forKey: of_file_attribute_key_type]; + [attributes setObject: OFFileTypeCharacterSpecial + forKey: OFFileType]; #endif #ifdef S_ISBLK else if (S_ISBLK(s->st_mode)) - [attributes setObject: of_file_type_block_special - forKey: of_file_attribute_key_type]; + [attributes setObject: OFFileTypeBlockSpecial + forKey: OFFileType]; #endif #ifdef S_ISSOCK else if (S_ISSOCK(s->st_mode)) - [attributes setObject: of_file_type_socket - forKey: of_file_attribute_key_type]; + [attributes setObject: OFFileTypeSocket forKey: OFFileType]; #endif + else + [attributes setObject: OFFileTypeUnknown forKey: OFFileType]; } static void -setDateAttributes(of_mutable_file_attributes_t 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: of_file_attribute_key_last_access_date]; + forKey: OFFileLastAccessDate]; [attributes setObject: [OFDate dateWithTimeIntervalSince1970: s->st_mtime] - forKey: of_file_attribute_key_modification_date]; + forKey: OFFileModificationDate]; [attributes setObject: [OFDate dateWithTimeIntervalSince1970: s->st_ctime] - forKey: of_file_attribute_key_status_change_date]; + forKey: OFFileStatusChangeDate]; #ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME [attributes setObject: [OFDate dateWithTimeIntervalSince1970: s->st_birthtime] - forKey: of_file_attribute_key_creation_date]; + forKey: OFFileCreationDate]; #endif } static void -setOwnerAndGroupAttributes(of_mutable_file_attributes_t attributes, - of_stat_t *s) +setOwnerAndGroupAttributes(OFMutableFileAttributes attributes, Stat *s) { #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER [attributes setObject: [NSNumber numberWithUnsignedLong: s->st_uid] - forKey: of_file_attribute_key_posix_uid]; + forKey: OFFileOwnerAccountID]; [attributes setObject: [NSNumber numberWithUnsignedLong: s->st_gid] - forKey: of_file_attribute_key_posix_gid]; + forKey: OFFileGroupOwnerAccountID]; # ifdef OF_HAVE_THREADS [passwdMutex lock]; @try { # endif - of_string_encoding_t encoding = [OFLocale encoding]; + OFStringEncoding 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]; [attributes setObject: owner - forKey: of_file_attribute_key_owner]; + forKey: OFFileOwnerAccountName]; } if (group_ != NULL) { OFString *group = [OFString stringWithCString: group_->gr_name encoding: encoding]; [attributes setObject: group - forKey: of_file_attribute_key_group]; + forKey: OFFileGroupOwnerAccountName]; } # ifdef OF_HAVE_THREADS } @finally { [passwdMutex unlock]; } @@ -455,20 +454,19 @@ #endif } #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS static void -setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes, +setSymbolicLinkDestinationAttribute(OFMutableFileAttributes attributes, OFURL *URL) { OFString *path = URL.fileSystemRepresentation; # ifndef OF_WINDOWS - of_string_encoding_t encoding = [OFLocale encoding]; + OFStringEncoding 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); if (length < 0) @@ -478,18 +476,17 @@ destination = [OFString stringWithCString: destinationC encoding: encoding length: length]; - key = of_file_attribute_key_symbolic_link_destination; [attributes setObject: destination - forKey: key]; + 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) @@ -502,11 +499,10 @@ char bytes[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; REPARSE_DATA_BUFFER data; } buffer; DWORD size; wchar_t *tmp; - of_file_attribute_key_t key; if (!DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer.bytes, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &size, NULL)) @throw [OFRetrieveItemAttributesFailedException @@ -525,15 +521,14 @@ destination = [OFString stringWithUTF16String: tmp length: slrb.SubstituteNameLength / sizeof(wchar_t)]; - [attributes setObject: of_file_type_symbolic_link - forKey: of_file_attribute_key_type]; - key = of_file_attribute_key_symbolic_link_destination; + [attributes setObject: OFFileTypeSymbolicLink + forKey: OFFileType]; [attributes setObject: destination - forKey: key]; + forKey: OFFileSymbolicLinkDestination]; # undef slrb } @finally { CloseHandle(handle); } # endif @@ -559,18 +554,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 @@ -582,20 +577,19 @@ [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); } -- (OFStream *)openItemAtURL: (OFURL *)URL - mode: (OFString *)mode +- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode { void *pool = objc_autoreleasePoolPush(); OFFile *file = [[OFFile alloc] initWithPath: URL.fileSystemRepresentation mode: mode]; @@ -603,41 +597,41 @@ objc_autoreleasePoolPop(pool); return [file autorelease]; } -- (of_file_attributes_t)attributesOfItemAtURL: (OFURL *)URL +- (OFFileAttributes)attributesOfItemAtURL: (OFURL *)URL { - of_mutable_file_attributes_t ret = [OFMutableDictionary dictionary]; + 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) @throw [OFOutOfRangeException exception]; [ret setObject: [NSNumber numberWithUnsignedLongLong: s.st_size] - forKey: of_file_attribute_key_size]; + forKey: OFFileSize]; setTypeAttribute(ret, &s); [ret setObject: [NSNumber numberWithUnsignedLong: s.st_mode] - forKey: of_file_attribute_key_posix_permissions]; + forKey: OFFilePOSIXPermissions]; setOwnerAndGroupAttributes(ret, &s); setDateAttributes(ret, &s); #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS @@ -651,32 +645,31 @@ } - (void)of_setLastAccessDate: (OFDate *)lastAccessDate andModificationDate: (OFDate *)modificationDate ofItemAtURL: (OFURL *)URL - attributes: (of_file_attributes_t)attributes OF_DIRECT + attributes: (OFFileAttributes)attributes OF_DIRECT { OFString *path = URL.fileSystemRepresentation; - of_file_attribute_key_t attributeKey = (modificationDate != nil - ? of_file_attribute_key_modification_date - : of_file_attribute_key_last_access_date); + OFFileAttributeKey attributeKey = (modificationDate != nil + ? OFFileModificationDate : OFFileLastAccessDate); if (lastAccessDate == nil) 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]; @@ -702,11 +695,11 @@ failedAttribute: attributeKey errNo: errno]; } #elif defined(OF_AMIGAOS) /* AmigaOS does not support access time. */ - of_time_interval_t modificationTime = + OFTimeInterval modificationTime = modificationDate.timeIntervalSince1970; struct Locale *locale; struct DateStamp date; modificationTime -= 252460800; /* 1978-01-01 */ @@ -738,13 +731,12 @@ exceptionWithURL: URL attributes: attributes failedAttribute: attributeKey errNo: retrieveError()]; #else - of_time_interval_t lastAccessTime = - lastAccessDate.timeIntervalSince1970; - of_time_interval_t modificationTime = + OFTimeInterval lastAccessTime = lastAccessDate.timeIntervalSince1970; + OFTimeInterval modificationTime = modificationDate.timeIntervalSince1970; struct timeval times[2] = { { .tv_sec = (time_t)lastAccessTime, .tv_usec = @@ -766,11 +758,11 @@ #endif } - (void)of_setPOSIXPermissions: (OFNumber *)permissions ofItemAtURL: (OFURL *)URL - attributes: (of_file_attributes_t)attributes OF_DIRECT + attributes: (OFFileAttributes)attributes OF_DIRECT { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS mode_t mode = (mode_t)permissions.unsignedLongValue; OFString *path = URL.fileSystemRepresentation; int status; @@ -785,28 +777,28 @@ if (status != 0) @throw [OFSetItemAttributesFailedException exceptionWithURL: URL attributes: attributes - failedAttribute: of_file_attribute_key_posix_permissions + failedAttribute: OFFilePOSIXPermissions errNo: errno]; #else OF_UNRECOGNIZED_SELECTOR #endif } -- (void)of_setOwner: (OFString *)owner - andGroup: (OFString *)group - ofItemAtURL: (OFURL *)URL - attributeKey: (of_file_attribute_key_t)attributeKey - attributes: (of_file_attributes_t)attributes OF_DIRECT +- (void)of_setOwnerAccountName: (OFString *)owner + andGroupOwnerAccountName: (OFString *)group + ofItemAtURL: (OFURL *)URL + attributeKey: (OFFileAttributeKey)attributeKey + attributes: (OFFileAttributes)attributes OF_DIRECT { #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER OFString *path = URL.fileSystemRepresentation; uid_t uid = -1; gid_t gid = -1; - of_string_encoding_t encoding; + OFStringEncoding encoding; if (owner == nil && group == nil) @throw [OFInvalidArgumentException exception]; encoding = [OFLocale encoding]; @@ -857,17 +849,16 @@ #else OF_UNRECOGNIZED_SELECTOR #endif } -- (void)setAttributes: (of_file_attributes_t)attributes - ofItemAtURL: (OFURL *)URL +- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); - OFEnumerator OF_GENERIC(of_file_attribute_key_t) *keyEnumerator; + OFEnumerator OF_GENERIC(OFFileAttributeKey) *keyEnumerator; OFEnumerator *objectEnumerator; - of_file_attribute_key_t key; + OFFileAttributeKey key; id object; OFDate *lastAccessDate, *modificationDate; if (URL == nil) @throw [OFInvalidArgumentException exception]; @@ -878,39 +869,37 @@ keyEnumerator = [attributes keyEnumerator]; objectEnumerator = [attributes objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) { - if ([key isEqual: of_file_attribute_key_modification_date] || - [key isEqual: of_file_attribute_key_last_access_date]) + if ([key isEqual: OFFileModificationDate] || + [key isEqual: OFFileLastAccessDate]) continue; - else if ([key isEqual: of_file_attribute_key_posix_permissions]) + else if ([key isEqual: OFFilePOSIXPermissions]) [self of_setPOSIXPermissions: object ofItemAtURL: URL attributes: attributes]; - else if ([key isEqual: of_file_attribute_key_owner]) - [self of_setOwner: object - andGroup: nil - ofItemAtURL: URL - attributeKey: key - attributes: attributes]; - else if ([key isEqual: of_file_attribute_key_group]) - [self of_setOwner: nil - andGroup: object - ofItemAtURL: URL - attributeKey: key - attributes: attributes]; + else if ([key isEqual: OFFileOwnerAccountName]) + [self of_setOwnerAccountName: object + andGroupOwnerAccountName: nil + ofItemAtURL: URL + attributeKey: key + attributes: attributes]; + else if ([key isEqual: OFFileGroupOwnerAccountName]) + [self of_setOwnerAccountName: nil + andGroupOwnerAccountName: object + ofItemAtURL: URL + attributeKey: key + attributes: attributes]; else @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; } - lastAccessDate = [attributes - objectForKey: of_file_attribute_key_last_access_date]; - modificationDate = [attributes - objectForKey: of_file_attribute_key_modification_date]; + lastAccessDate = [attributes objectForKey: OFFileLastAccessDate]; + modificationDate = [attributes objectForKey: OFFileModificationDate]; if (lastAccessDate != nil || modificationDate != nil) [self of_setLastAccessDate: lastAccessDate andModificationDate: modificationDate ofItemAtURL: URL @@ -920,20 +909,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); @@ -944,20 +933,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); @@ -1011,13 +1000,13 @@ #endif objc_autoreleasePoolPop(pool); } -- (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtURL: (OFURL *)URL +- (OFArray OF_GENERIC(OFURL *) *)contentsOfDirectoryAtURL: (OFURL *)URL { - OFMutableArray *files = [OFMutableArray array]; + OFMutableArray *URLs = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); OFString *path; if (URL == nil) @throw [OFInvalidArgumentException exception]; @@ -1051,11 +1040,12 @@ continue; file = [[OFString alloc] initWithUTF16String: fd.cFileName]; @try { - [files addObject: file]; + [URLs addObject: [URL + URLByAppendingPathComponent: file]]; } @finally { [file release]; } } while (FindNextFileW(handle, &fd)); @@ -1066,11 +1056,11 @@ errNo: retrieveError()]; } @finally { FindClose(handle); } } else { - of_string_encoding_t encoding = [OFLocale encoding]; + OFStringEncoding encoding = [OFLocale encoding]; WIN32_FIND_DATA fd; if ((handle = FindFirstFileA( [path cStringWithEncoding: encoding], &fd)) == INVALID_HANDLE_VALUE) @@ -1089,11 +1079,12 @@ file = [[OFString alloc] initWithCString: fd.cFileName encoding: encoding]; @try { - [files addObject: file]; + [URLs addObject: [URL + URLByAppendingPathComponent: file]]; } @finally { [file release]; } } while (FindNextFileA(handle, &fd)); @@ -1105,11 +1096,11 @@ } @finally { FindClose(handle); } } #elif defined(OF_AMIGAOS) - of_string_encoding_t encoding = [OFLocale encoding]; + OFStringEncoding encoding = [OFLocale encoding]; BPTR lock; if ((lock = Lock([path cStringWithEncoding: encoding], SHARED_LOCK)) == 0) @throw [OFOpenItemFailedException @@ -1135,11 +1126,12 @@ OFString *file = [[OFString alloc] initWithCString: ed->Name encoding: encoding]; @try { - [files addObject: file]; + [URLs addObject: [URL + URLByAppendingPathComponent: file]]; } @finally { [file release]; } } } @finally { @@ -1156,13 +1148,13 @@ while (ExNext(lock, &fib)) { OFString *file = [[OFString alloc] initWithCString: fib.fib_FileName encoding: encoding]; - @try { - [files addObject: file]; + [URLs addObject: + [URL URLByAppendingPathComponent: file]]; } @finally { [file release]; } } # endif @@ -1174,13 +1166,12 @@ errNo: retrieveError()]; } @finally { UnLock(lock); } #else - of_string_encoding_t encoding = [OFLocale encoding]; + OFStringEncoding encoding = [OFLocale encoding]; DIR *dir; - if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL) @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil errNo: errno]; @@ -1228,11 +1219,12 @@ continue; file = [[OFString alloc] initWithCString: dirent->d_name encoding: encoding]; @try { - [files addObject: file]; + [URLs addObject: + [URL URLByAppendingPathComponent: file]]; } @finally { [file release]; } } } @finally { @@ -1241,38 +1233,38 @@ [readdirMutex unlock]; # endif } #endif - [files makeImmutable]; + [URLs makeImmutable]; objc_autoreleasePoolPop(pool); - return files; + return URLs; } - (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 *contents; + OFArray OF_GENERIC(OFURL *) *contents; @try { contents = [self contentsOfDirectoryAtURL: URL]; } @catch (id e) { /* @@ -1288,15 +1280,14 @@ errNo: [e errNo]]; @throw e; } - for (OFString *item in contents) { + for (OFURL *item in contents) { void *pool2 = objc_autoreleasePoolPush(); - [self removeItemAtURL: [OFURL fileURLWithPath: - [path stringByAppendingPathComponent: item]]]; + [self removeItemAtURL: item]; objc_autoreleasePoolPop(pool2); } #ifndef OF_AMIGAOS @@ -1341,12 +1332,11 @@ objc_autoreleasePoolPop(pool); } #ifdef OF_FILE_MANAGER_SUPPORTS_LINKS -- (void)linkItemAtURL: (OFURL *)source - toURL: (OFURL *)destination +- (void)linkItemAtURL: (OFURL *)source toURL: (OFURL *)destination { void *pool = objc_autoreleasePoolPush(); OFString *sourcePath, *destinationPath; if (source == nil || destination == nil) @@ -1358,24 +1348,24 @@ sourcePath = source.fileSystemRepresentation; destinationPath = destination.fileSystemRepresentation; # ifndef OF_WINDOWS - of_string_encoding_t encoding = [OFLocale encoding]; + OFStringEncoding encoding = [OFLocale encoding]; if (link([sourcePath cStringWithEncoding: encoding], [destinationPath cStringWithEncoding: encoding]) != 0) @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()]; @@ -1399,24 +1389,25 @@ @throw [OFInvalidArgumentException exception]; path = URL.fileSystemRepresentation; # ifndef OF_WINDOWS - of_string_encoding_t encoding = [OFLocale encoding]; + OFStringEncoding encoding = [OFLocale encoding]; if (symlink([target cStringWithEncoding: encoding], [path cStringWithEncoding: encoding]) != 0) @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 @@ -1423,12 +1414,11 @@ objc_autoreleasePoolPop(pool); } #endif -- (bool)moveItemAtURL: (OFURL *)source - toURL: (OFURL *)destination +- (bool)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination { void *pool; if (![source.scheme isEqual: _scheme] || ![destination.scheme isEqual: _scheme]) @@ -1441,11 +1431,11 @@ errNo: EEXIST]; pool = objc_autoreleasePoolPush(); #ifdef OF_AMIGAOS - of_string_encoding_t encoding = [OFLocale encoding]; + OFStringEncoding encoding = [OFLocale encoding]; if (!Rename([source.fileSystemRepresentation cStringWithEncoding: encoding], [destination.fileSystemRepresentation cStringWithEncoding: encoding])) @@ -1460,11 +1450,11 @@ if ([OFSystemInfo isWindowsNT]) status = _wrename(source.fileSystemRepresentation.UTF16String, destination.fileSystemRepresentation.UTF16String); else { # endif - of_string_encoding_t encoding = [OFLocale encoding]; + OFStringEncoding encoding = [OFLocale encoding]; status = rename([source.fileSystemRepresentation cStringWithEncoding: encoding], [destination.fileSystemRepresentation cStringWithEncoding: encoding]);