Isn't the path returned by NSDirectoryEnumerator a relative path to the path 
you initialize it with?

The docs say: "An NSDirectoryEnumerator object enumerates the contents of a 
directory, returning the pathnames of all files and directories contained 
within that directory. These pathnames are relative to the directory."

Have a look at the value of <aPath> - you might need to append it to the string 
path of the folderURL...unless your <engine> is appending it.


On Jan 13, 2010, at 1:32 PM, Jamie Hardt wrote:

> Hello all,
> 
> I'm using a directory enumerator to recurse through a series of directories, 
> and it always fails after going through a certain number of enumerations.  If 
> I enumerate through the same directory over and over, it tends to fail in 
> about the same place, but if I enumerate through other directories, it will 
> fail but after completing a different number of enumerations, so I don't 
> think it's necessarily a memory thing or something wrong with my file system.
> 
> It always comes back with the same error number (256), which macerror cannot 
> identify:
> 
> "2010-01-13 10:14:34.078 afindex[821:1b03] directoryEnumerator failed on enum 
> 1598, error description: The operation couldn\U2019t be completed. 
> (NSCocoaErrorDomain error 256.)"
> 
> Here's my code, I can't figure out why it's failing...
> 
> /* enumeration.m */
> 
> __block NSUInteger i = 0;
> NSFileManager *fm = [[NSFileManager alloc] init];
> NSDirectoryEnumerator *dirEnum = [fm enumeratorAtURL:folderURL
>                includingPropertiesForKeys:nil
>                              options:NSDirectoryEnumerationSkipsHiddenFiles ^ 
> NSDirectoryEnumerationSkipsPackageDescendants
>                          errorHandler:^(NSURL *url, NSError *error){
>                             NSLog(@"directoryEnumerator failed on enum %i, 
> error description: %@",i,[error localizedDescription]);
>                             return NO;
>                          }];
> 
> 
> NSAutoreleasePool *ap = [[NSAutoreleasePool alloc] init];
> NSURL *aPath;
> while (aPath = [dirEnum nextObject]) {
> if ( 1 ) {
>  NSDictionary *metadataDict = [engine metadataDictionaryForFile:[aPath path] 
> ];
>  [database indexMetadata:metadataDict forFileAtURL:aPath];
> }
> if (++i % 50 == 0 ) {
>  [ap release];
>  ap = [[NSAutoreleasePool alloc] init];
> }
> 
> }
> [path release];
> [ap release];
> [fm release];
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to