@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2021 Jonathan Schleifer + * Copyright (c) 2008-2022 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -65,43 +65,23 @@ #ifdef OF_AMIGAOS # include # include #endif + +#ifdef OF_MINT +# include +#endif @interface OFDefaultFileManager: OFFileManager @end -const OFFileAttributeKey OFFileSize = @"OFFileSize"; -const OFFileAttributeKey OFFileType = @"OFFileType"; -const OFFileAttributeKey OFFilePOSIXPermissions = @"OFFilePOSIXPermissions"; -const OFFileAttributeKey OFFileOwnerAccountID = @"OFFileOwnerAccountID"; -const OFFileAttributeKey OFFileGroupOwnerAccountID = - @"OFFileGroupOwnerAccountID"; -const OFFileAttributeKey OFFileOwnerAccountName = @"OFFileOwnerAccountName"; -const OFFileAttributeKey OFFileGroupOwnerAccountName = - @"OFFileGroupOwnerAccountName"; -const OFFileAttributeKey OFFileLastAccessDate = @"OFFileLastAccessDate"; -const OFFileAttributeKey OFFileModificationDate = @"OFFileModificationDate"; -const OFFileAttributeKey OFFileStatusChangeDate = @"OFFileStatusChangeDate"; -const OFFileAttributeKey OFFileCreationDate = @"OFFileCreationDate"; -const OFFileAttributeKey OFFileSymbolicLinkDestination = - @"OFFileSymbolicLinkDestination"; - -const OFFileAttributeType OFFileTypeRegular = @"OFFileTypeRegular"; -const OFFileAttributeType OFFileTypeDirectory = @"OFFileTypeDirectory"; -const OFFileAttributeType OFFileTypeSymbolicLink = @"OFFileTypeSymbolicLink"; -const OFFileAttributeType OFFileTypeFIFO = @"OFFileTypeFIFO"; -const OFFileAttributeType OFFileTypeCharacterSpecial = - @"OFFileTypeCharacterSpecial"; -const OFFileAttributeType OFFileTypeBlockSpecial = @"OFFileTypeBlockSpecial"; -const OFFileAttributeType OFFileTypeSocket = @"OFFileTypeSocket"; -const OFFileAttributeType OFFileTypeUnknown = @"OFFileTypeUnknown"; - #ifdef OF_AMIGAOS4 # define CurrentDir(lock) SetCurrentDir(lock) #endif + +#include "OFFileManagerConstants.inc" static OFFileManager *defaultManager; #ifdef OF_AMIGAOS static bool dirChanged = false; @@ -470,10 +450,41 @@ ret = [OFMutableArray arrayWithCapacity: URLs.count]; for (OFURL *URL in URLs) [ret addObject: URL.lastPathComponent]; + [ret makeImmutable]; + [ret retain]; + + objc_autoreleasePoolPop(pool); + + return [ret autorelease]; +} + +- (OFArray OF_GENERIC(OFString *) *)subpathsOfDirectoryAtPath: (OFString *)path +{ + void *pool = objc_autoreleasePoolPush(); + OFMutableArray OF_GENERIC(OFString *) *ret = + [OFMutableArray arrayWithObject: path]; + + for (OFString *subpath in [self contentsOfDirectoryAtPath: path]) { + void *pool2 = objc_autoreleasePoolPush(); + OFString *fullSubpath = + [path stringByAppendingPathComponent: subpath]; + OFFileAttributes attributes = + [self attributesOfItemAtPath: fullSubpath]; + + if ([attributes.fileType isEqual: OFFileTypeDirectory]) + [ret addObjectsFromArray: + [self subpathsOfDirectoryAtPath: fullSubpath]]; + else + [ret addObject: fullSubpath]; + + objc_autoreleasePoolPop(pool2); + } + + [ret makeImmutable]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease];