Skip to content

Commit

Permalink
Merge pull request #419 from 2xsaiko/outgoing/nsfmurls
Browse files Browse the repository at this point in the history
Implement -[NSFileManager URLsForDirectory:inDomains:]
  • Loading branch information
rfm authored Jun 12, 2024
2 parents ced4cd0 + 952e076 commit 92247d1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2024-06-10 Marco Rebhan <[email protected]>

* Headers/Foundation/NSFileManager.h:
* Source/NSFileManager.m:
Implement -[NSFileManager URLsForDirectory:inDomains:].

2024-06-10 Richard Frith-Macdonald <[email protected]>

* Source/GSFileHandle.m: debug log of closing a closed file handle
Expand Down
15 changes: 15 additions & 0 deletions Headers/Foundation/NSFileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,21 @@ GS_EXPORT_CLASS
create: (BOOL)shouldCreate
error: (NSError **)error;

/**
* Returns an array of search paths to look at for resources.<br/ >
* The paths are returned in domain order:
* USER, LOCAL, NETWORK then SYSTEM.<br />
* The presence of a path in this list does <em>not</em> mean that the
* path actually exists in the filesystem.<br />
* If you are wanting to locate an existing resource, you should normally
* call this method with NSAllDomainsMask, but if you wish to find the
* path in which you should create a new file, you would generally
* specify a particular domain, and then create the path in the file
* system if it does not already exist.
*/
- (GS_GENERIC_CLASS(NSArray, NSURL *) *)URLsForDirectory: (NSSearchPathDirectory)directory
inDomains: (NSSearchPathDomainMask)domain;

/**
* Enumerate over the contents of a directory.
*/
Expand Down
1 change: 0 additions & 1 deletion MISSING
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ NSFileManager:

- mountedVolumeURLsIncludingResourceValuesForKeys:options:
- contentsOfDirectoryAtURL:includingPropertiesForKeys:options:error:
- URLsForDirectory:inDomains:
- createDirectoryAtURL:withIntermediateDirectories:attributes:error:
- createSymbolicLinkAtURL:withDestinationURL:error:
- setDelegate:
Expand Down
15 changes: 15 additions & 0 deletions Source/NSFileManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -925,6 +926,20 @@ - (NSURL *)URLForDirectory: (NSSearchPathDirectory)directory
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
Expand Down

0 comments on commit 92247d1

Please sign in to comment.