I am trying to enumerate the contents of a directory. The code I use is this:
However, the result I am getting is that some folders are missing from the enumeration! Here is my result:
Below is the image which shows the contents of the specified directory. You can clearly see that some folders are missing such as "testdirasdasdasdasdas" . I am using leopard and Xcode 3.1.
EDIT: I noticed that in some cases it works, is some others it doesn't, especially for recently created files and folders!!
Can anyone help?
Code:
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSFileManager *fm = [NSFileManager defaultManager];
NSString *fs2OpenDirectory = [@"/Volumes/MECOS/GAMES/FreeSpace2/FS2_Open-20080717_trunk.app" stringByDeletingLastPathComponent];
NSDirectoryEnumerator *dirEnum = [fm enumeratorAtPath:fs2OpenDirectory];
NSString *file;
while (file = [dirEnum nextObject]){
[dirEnum skipDescendents];
//NSDictionary *fileAttr = [fm fileAttributesAtPath:[fs2OpenDirectoryContents objectAtIndex:i] traverseLink:NO];
NSLog(file);
}
[pool drain];
return 0;
}
However, the result I am getting is that some folders are missing from the enumeration! Here is my result:
Code:
2008-11-22 14:05:02.421 foundationtooltest[1409:10b] .DS_Store
2008-11-22 14:05:02.425 foundationtooltest[1409:10b] bluePlanet
2008-11-22 14:05:02.426 foundationtooltest[1409:10b] data
2008-11-22 14:05:02.426 foundationtooltest[1409:10b] derelict
2008-11-22 14:05:02.427 foundationtooltest[1409:10b] ereg
2008-11-22 14:05:02.427 foundationtooltest[1409:10b] FreeSpaceOpenInstaller.jar
2008-11-22 14:05:02.428 foundationtooltest[1409:10b] FS2_Open 3.6.9 (debug).app
2008-11-22 14:05:02.430 foundationtooltest[1409:10b] FS2_Open 3.6.9.app
2008-11-22 14:05:02.432 foundationtooltest[1409:10b] FS2_Open-20080717_trunk (debug).app
2008-11-22 14:05:02.435 foundationtooltest[1409:10b] FS2_Open-20080717_trunk.app
2008-11-22 14:05:02.439 foundationtooltest[1409:10b] FS2_Open-Xt_1208.app
2008-11-22 14:05:02.441 foundationtooltest[1409:10b] FS2_Open_0414.app
2008-11-22 14:05:02.442 foundationtooltest[1409:10b] FS2MissionsCRCs.txt
2008-11-22 14:05:02.444 foundationtooltest[1409:10b] FS2OGGcutscenepack.vp
2008-11-22 14:05:02.444 foundationtooltest[1409:10b] fs2uninst.dll
2008-11-22 14:05:02.445 foundationtooltest[1409:10b] fsport
2008-11-22 14:05:02.448 foundationtooltest[1409:10b] Installer
2008-11-22 14:05:02.450 foundationtooltest[1409:10b] launcher6.ini
2008-11-22 14:05:02.451 foundationtooltest[1409:10b] mp-710_adveffects.vp
2008-11-22 14:05:02.451 foundationtooltest[1409:10b] mp-710_effects.vp
2008-11-22 14:05:02.452 foundationtooltest[1409:10b] mp-710_models.vp
2008-11-22 14:05:02.452 foundationtooltest[1409:10b] multi-mission-pack.vp
2008-11-22 14:05:02.457 foundationtooltest[1409:10b] multi-voice-pack.vp
2008-11-22 14:05:02.458 foundationtooltest[1409:10b] mv_adveffects.vp
2008-11-22 14:05:02.458 foundationtooltest[1409:10b] mv_core.vp
2008-11-22 14:05:02.459 foundationtooltest[1409:10b] mv_effects.vp
2008-11-22 14:05:02.460 foundationtooltest[1409:10b] mv_models.vp
2008-11-22 14:05:02.461 foundationtooltest[1409:10b] mv_music.vp
2008-11-22 14:05:02.461 foundationtooltest[1409:10b] mv_textures.vp
2008-11-22 14:05:02.462 foundationtooltest[1409:10b] old FS2_Launcher 4.app
2008-11-22 14:05:02.465 foundationtooltest[1409:10b] patchw32.dll
2008-11-22 14:05:02.467 foundationtooltest[1409:10b] root_fs2.vp
2008-11-22 14:05:02.468 foundationtooltest[1409:10b] smarty_fs2.vp
2008-11-22 14:05:02.469 foundationtooltest[1409:10b] sparky_fs2.vp
2008-11-22 14:05:02.469 foundationtooltest[1409:10b] sparky_hi_fs2.vp
2008-11-22 14:05:02.470 foundationtooltest[1409:10b] stu_fs2.vp
2008-11-22 14:05:02.470 foundationtooltest[1409:10b] tango1_fs2.vp
2008-11-22 14:05:02.510 foundationtooltest[1409:10b] tango2_fs2.vp
2008-11-22 14:05:02.528 foundationtooltest[1409:10b] tango3_fs2.vp
2008-11-22 14:05:02.529 foundationtooltest[1409:10b] tangoA_fs2.vp
2008-11-22 14:05:02.530 foundationtooltest[1409:10b] temp
2008-11-22 14:05:02.531 foundationtooltest[1409:10b] tools
2008-11-22 14:05:02.532 foundationtooltest[1409:10b] Transcend
2008-11-22 14:05:02.533 foundationtooltest[1409:10b] Uninst.isu
2008-11-22 14:05:02.533 foundationtooltest[1409:10b] warble_fs2.vp
2008-11-22 14:05:02.534 foundationtooltest[1409:10b] Warzone
Below is the image which shows the contents of the specified directory. You can clearly see that some folders are missing such as "testdirasdasdasdasdas" . I am using leopard and Xcode 3.1.
EDIT: I noticed that in some cases it works, is some others it doesn't, especially for recently created files and folders!!
Can anyone help?