Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement -[NSFileManager URLsForDirectory:inDomains:] #419

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -200,7 +200,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
Loading