@@ -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];