//
// main.m
// FileSearchTest
//
// Created by Zhang Leonardo on 11-10-31.
// Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
// To discuss via :www.renren.com/leonardozhang
//
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
@autoreleasepool {
NSFileManager *manager = [NSFileManager defaultManager];
//如果是相对相对路径转换为绝对路径
NSString *home = [@"/Users/tang/desktop/123" stringByExpandingTildeInPath];
NSLog(@"home: %@", home);
//列举出文件路径下的目录
NSDirectoryEnumerator *direnum = [manager enumeratorAtPath:home];
NSMutableArray *files = [NSMutableArray arrayWithCapacity:42];
NSString *filename ;
while (filename = [direnum nextObject]) {
[files addObject: filename];
// if ([[filename pathExtension] isEqualTo:@"jpg"]) {
// [files addObject: filename];
// }
}
NSEnumerator *fileenum;
fileenum = [files objectEnumerator];
for (id filePath in fileenum) {
NSLog(@"%@", filePath);
}
// while (filename = [fileenum nextObject]) {
// NSLog(@"%@", filename);
// }
}
return 0;
}