This commit is contained in:
rfm 2023-11-14 20:55:22 +00:00
parent 41ad571889
commit e8b67e3e0b
3 changed files with 42 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2023-11-14 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSFileManager.m: Fix issue #292
* Tests/base/NSFileManager/general.m: test for enumerator at URL
2023-11-14 Richard Frith-Macdonald <rfm@gnu.org> Riccardo Mottola <rm@gnu.org>
* Documentation/Base.gsdoc:

View file

@ -196,6 +196,9 @@
- (void) _setErrorHandler: (GSDirEnumErrorHandler) handler;
@end
@interface GSURLEnumerator : NSDirectoryEnumerator
@end
/*
* Macros to handle unichar filesystem support.
*/
@ -918,8 +921,8 @@ static NSStringEncoding defaultEncoding;
return [NSURL fileURLWithPath: path];
}
- (NSDirectoryEnumerator *)enumeratorAtURL: (NSURL *)url
includingPropertiesForKeys: (NSArray *)keys
- (NSDirectoryEnumerator*) enumeratorAtURL: (NSURL*)url
includingPropertiesForKeys: (NSArray*)keys
options: (NSDirectoryEnumerationOptions)mask
errorHandler: (GSDirEnumErrorHandler)handler
{
@ -956,7 +959,7 @@ static NSStringEncoding defaultEncoding;
shouldSkipHidden = NO;
}
direnum = [[NSDirectoryEnumerator alloc]
direnum = [[GSURLEnumerator alloc]
initWithDirectoryPath: path
recurseIntoSubdirectories: shouldRecurse
followSymlinks: NO
@ -2981,6 +2984,15 @@ static inline void gsedRelease(GSEnumeratedDirectory X)
@end /* NSDirectoryEnumerator */
@implementation GSURLEnumerator
- (id) nextObject
{
id name = [super nextObject];
return name ? [NSURL fileURLWithPath: name] : nil;
}
@end
/**
* Convenience methods for accessing named file attributes in a dictionary.
*/

View file

@ -272,6 +272,28 @@ NSLog(@"%@\n%@", oa, na);
PASS([mgr createDirectoryAtPath: @"subdir" attributes: nil],
"NSFileManager can create a subdirectory");
{
NSURL *u;
NSDirectoryEnumerator *e;
unsigned found = 0;
e = [mgr enumeratorAtURL: [NSURL fileURLWithPath: @"."]
includingPropertiesForKeys: nil
options: 0
errorHandler: nil];
while (nil != (u = [e nextObject]))
{
NSString *c = [[u path] lastPathComponent];
if ([c isEqualToString: @"NSFMCopy"])
found++;
if ([c isEqualToString: @"subdir"])
found++;
}
PASS(2 == found, "URL enumerator finds expected file and subdirectory")
}
PASS([mgr changeCurrentDirectoryPath: @"subdir"],
"NSFileManager can move into subdir");