I am working on a little app for my Mac that will scan directories for a file type like, "mov" files. I have NSOpenPanel pop up and then I select the directory and when I hit OK It saves the directory to an NSMutableArray. I then sort through the Array to see if the file is of .mov type or another directory. If it is a mov I save it to a new array or if it finds a directory it saves it to a different array. It works fine except it is adding anything with .app extension to the directory array. here is a list of the results and code. At the bottom you can see the XP.....app
After the OK button is pressed on the NSOpenPanel window
2011-11-25 21:40:27.783 Mov Catalog[5577:903] Mov Array has (
"dynamics_reel.mov",
"LaCumbre_Comp.mov",
"sandbar_30.mov",
"SkyHighSports.mov",
"sy_fly_in.mov",
"UNIT-0004 Bonqo BelievesMed_prog.mov"
)
2011-11-25 21:40:27.784 Mov Catalog[5577:903] dir Array had (
"3D camera rig",
"4-23-11 invoice",
"aug 11 hotel invoice",
bf,
BLANK,
"Canon 7D CineStyle",
"My Music Bouce",
pascal,
"Porsche Photos",
"red dwarf 8",
"stopwatch stills",
"xCode Videos",
"Xp Calc9.3.app",
"Xp Calc_9.2.app",
"Xp Calc_v9.1.app",
"YMCA Zoe"
)
After the OK button is pressed on the NSOpenPanel window
Code:
if (result == NSOKButton){
BOOL dirPathVerify = NO;
dirPath = [[NSString alloc]initWithFormat:[getFile filename]];
NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:dirPath error:nil];
for (int i = 0; i < dirContents.count; i++) {
NSString *aPath = [dirContents objectAtIndex:i];
NSString *fullPath = [dirPath stringByAppendingPathComponent:aPath];
if ([filemgr fileExistsAtPath:fullPath isDirectory: &dirPathVerify] &&dirPathVerify ) {
[dirArray addObject:aPath];
}
else if ([[aPath pathExtension] isEqualToString:@"mov"]) {
[movArray addObject:aPath];
}
}
NSLog(@"Mov Array has %@", movArray);
NSLog(@"dir Array had %@", dirArray);
}
[movArray release];
[dirArray release];
}