Index: src/OFFileManager.h ================================================================== --- src/OFFileManager.h +++ src/OFFileManager.h @@ -389,18 +389,19 @@ */ - (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtPath: (OFString *)path; #endif /** - * @brief Returns an array with the items in the specified directory. + * @brief Returns an array with the URLs of the items in the specified + * directory. * * @note `.` and `..` are not part of the returned array. * * @param URL The URL to the directory whose items should be returned - * @return An array of OFString with the items in the specified directory + * @return An array with the URLs of the items in the specified directory */ -- (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtURL: (OFURL *)URL; +- (OFArray OF_GENERIC(OFURL *) *)contentsOfDirectoryAtURL: (OFURL *)URL; #ifdef OF_HAVE_FILES /** * @brief Changes the current working directory. * Index: src/OFFileManager.m ================================================================== --- src/OFFileManager.m +++ src/OFFileManager.m @@ -454,11 +454,11 @@ objc_autoreleasePoolPop(pool); } #endif -- (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtURL: (OFURL *)URL +- (OFArray OF_GENERIC(OFURL *) *)contentsOfDirectoryAtURL: (OFURL *)URL { OFURLHandler *URLHandler; if (URL == nil) @throw [OFInvalidArgumentException exception]; @@ -471,13 +471,18 @@ #ifdef OF_HAVE_FILES - (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); - OFArray OF_GENERIC(OFString *) *ret; + OFArray OF_GENERIC(OFURL *) *URLs; + OFMutableArray OF_GENERIC(OFString *) *ret; - ret = [self contentsOfDirectoryAtURL: [OFURL fileURLWithPath: path]]; + URLs = [self contentsOfDirectoryAtURL: [OFURL fileURLWithPath: path]]; + ret = [OFMutableArray arrayWithCapacity: URLs.count]; + + for (OFURL *URL in URLs) + [ret addObject: URL.lastPathComponent]; [ret retain]; objc_autoreleasePoolPop(pool); @@ -595,11 +600,11 @@ } type = attributes.fileType; if ([type isEqual: of_file_type_directory]) { - OFArray *contents; + OFArray OF_GENERIC(OFURL *) *contents; @try { [self createDirectoryAtURL: destination]; @try { @@ -635,20 +640,17 @@ errNo: [e errNo]]; @throw e; } - for (OFString *item in contents) { + for (OFURL *item in contents) { void *pool2 = objc_autoreleasePoolPush(); - OFURL *sourceURL, *destinationURL; - - sourceURL = - [source URLByAppendingPathComponent: item]; - destinationURL = - [destination URLByAppendingPathComponent: item]; - - [self copyItemAtURL: sourceURL toURL: destinationURL]; + OFURL *destinationURL = [destination + URLByAppendingPathComponent: + item.lastPathComponent]; + + [self copyItemAtURL: item toURL: destinationURL]; objc_autoreleasePoolPop(pool2); } } else if ([type isEqual: of_file_type_regular]) { size_t pageSize = [OFSystemInfo pageSize]; Index: src/OFFileURLHandler.m ================================================================== --- src/OFFileURLHandler.m +++ src/OFFileURLHandler.m @@ -1010,13 +1010,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]; @@ -1050,11 +1050,12 @@ continue; file = [[OFString alloc] initWithUTF16String: fd.cFileName]; @try { - [files addObject: file]; + [URLs addObject: [URL + URLByAppendingPathComponent: file]]; } @finally { [file release]; } } while (FindNextFileW(handle, &fd)); @@ -1088,11 +1089,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)); @@ -1134,11 +1136,12 @@ OFString *file = [[OFString alloc] initWithCString: ed->Name encoding: encoding]; @try { - [files addObject: file]; + [URLs addObject: [URL + URLByAppendingPathComponent: file]]; } @finally { [file release]; } } } @finally { @@ -1156,11 +1159,12 @@ 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 @@ -1225,11 +1229,12 @@ continue; file = [[OFString alloc] initWithCString: dirent->d_name encoding: encoding]; @try { - [files addObject: file]; + [URLs addObject: + [URL URLByAppendingPathComponent: file]]; } @finally { [file release]; } } } @finally { @@ -1238,15 +1243,15 @@ [readdirMutex unlock]; # endif } #endif - [files makeImmutable]; + [URLs makeImmutable]; objc_autoreleasePoolPop(pool); - return files; + return URLs; } - (void)removeItemAtURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); @@ -1265,11 +1270,11 @@ if ((error = of_lstat(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) { /* @@ -1285,15 +1290,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 Index: src/OFURLHandler.h ================================================================== --- src/OFURLHandler.h +++ src/OFURLHandler.h @@ -135,18 +135,19 @@ * @param URL The URL of the directory to create */ - (void)createDirectoryAtURL: (OFURL *)URL; /** - * @brief Returns an array with the items in the specified directory. + * @brief Returns an array with the URLs of the items in the specified + * directory. * * @note `.` and `..` are not part of the returned array. * * @param URL The URL to the directory whose items should be returned - * @return An array of OFString with the items in the specified directory + * @return An array with the URLs of the items in the specified directory */ -- (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtURL: (OFURL *)URL; +- (OFArray OF_GENERIC(OFURL *) *)contentsOfDirectoryAtURL: (OFURL *)URL; /** * @brief Removes the item at the specified URL. * * If the item at the specified URL is a directory, it is removed recursively. Index: src/OFURLHandler.m ================================================================== --- src/OFURLHandler.m +++ src/OFURLHandler.m @@ -164,11 +164,11 @@ - (void)createDirectoryAtURL: (OFURL *)URL { OF_UNRECOGNIZED_SELECTOR } -- (OFArray OF_GENERIC(OFString *) *)contentsOfDirectoryAtURL: (OFURL *)URL +- (OFArray OF_GENERIC(OFURL *) *)contentsOfDirectoryAtURL: (OFURL *)URL { OF_UNRECOGNIZED_SELECTOR } - (void)removeItemAtURL: (OFURL *)URL