I am noticing an error with the 'bog standard' Objective-C folder detection code. I am scanning files and folders with a given path and keeping count of how many files exist and how many folders exist.
Oddly enough, I am returning a count of one more folder than actually exists!
Stepping through the routine with debug and watching each file/folder name as the routine determines if the object is a file or folder, is showing me that one of the files is passing the test of being a folder!?!?!?
The file that is being detected incorrectly is an 'RTF with attachments (RTFD)' file type. I haven't checked other folders yet to see if there are more file types that might report themselves incorrectly.
Apart from this one file, everything else in my program is working correctly.
Does anyone have any ideas what I might be doing incorrectly? Or is it a known bug in Objective-C?
Here is part of the code I am using:
BOOL isDir;
NSString *file;
NSString *docsDir = [self path];
NSFileManager *manager = [NSFileManager defaultManager];
NSDirectoryEnumerator *dirEnum = [manager enumeratorAtPath: docsDir];
NSDictionary *fattrs;
//(only showing important declarations above)
while (file = [dirEnum nextObject]) {
//If user clicked the Abort Button, get out of the loop
if (abortFlag)
break;
if ([excludeSubdirectories state] == NSOnState) {
[dirEnum skipDescendents];
}
if ([manager fileExistsAtPath:[docsDir stringByAppendingPathComponent:file]
isDirectory:&isDir] && isDir) {
++dirCount;
if ([excludeSubdirectories state] == NSOnState) {
continue;
}
}
}
//... Do a bunch of other stuff, etc., etc. ...