Skip to content

Instantly share code, notes, and snippets.

@sc68cal
Created September 28, 2011 17:51
Show Gist options
  • Save sc68cal/1248652 to your computer and use it in GitHub Desktop.
Save sc68cal/1248652 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
#import <dirent.h>
int main(){
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
DIR *dp = opendir("/usr/share/man/man3");
struct dirent *dpr;
NSFileManager *manager = [NSFileManager defaultManager];
NSArray *output = [NSArray arrayWithObjects:
[NSMutableArray array],
[NSMutableArray array],
nil];
int i;
while((dpr = readdir(dp)))
[[output objectAtIndex:(dpr->d_type != 4)] addObject:[manager stringWithFileSystemRepresentation:dpr->d_name length:dpr->d_namlen]];
for(i=0; i<2;i++){
[[output objectAtIndex:i] sortUsingSelector:@selector(caseInsensitiveCompare:)];
for(NSString *name in [output objectAtIndex:i])
NSLog(@"%@", name);
}
[pool release]; return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment