Implement -[NSFileManager URLsForDirectory:inDomains:]

This commit is contained in:
Marco Rebhan 2024-06-10 20:40:39 +02:00
parent 930b901558
commit 952e076084
No known key found for this signature in database
4 changed files with 36 additions and 1 deletions

View file

@ -59,6 +59,7 @@
#import "Foundation/NSSet.h"
#import "Foundation/NSURL.h"
#import "Foundation/NSValue.h"
#import "GSFastEnumeration.h"
#import "GSPrivate.h"
#import "GSPThread.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
@ -925,6 +926,20 @@ static gs_mutex_t classLock = GS_MUTEX_INIT_STATIC;
return [NSURL fileURLWithPath: path];
}
- (GS_GENERIC_CLASS(NSArray, NSURL *) *)URLsForDirectory: (NSSearchPathDirectory)directory
inDomains: (NSSearchPathDomainMask)domain
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(directory, domain, YES);
NSMutableArray *urls = [[NSMutableArray alloc] initWithCapacity: paths.count];
FOR_IN(NSString *, path, paths)
[urls addObject: [NSURL fileURLWithPath: path]];
END_FOR_IN(paths)
RELEASE(paths);
return urls;
}
- (NSDirectoryEnumerator*) enumeratorAtURL: (NSURL*)url
includingPropertiesForKeys: (NSArray*)keys
options: (NSDirectoryEnumerationOptions)mask