Created
September 28, 2011 17:51
-
-
Save sc68cal/1248652 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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