标签:
- (NSInteger)codeLinesWithPath:(NSString *)path{ NSFileManager *fileManaget = [NSFileManager defaultManager]; BOOL isDir = NO; BOOL isExist = [fileManaget fileExistsAtPath:path isDirectory:&isDir]; if (!isExist) { return 0; } if (isDir) {//文件夹 NSArray *arr = [fileManaget contentsOfDirectoryAtPath:path error:nil]; int sum = 0; for (NSString *fileName in arr) {//文件(夹) NSString *fullPath = [NSString stringWithFormat:@"%@/%@",path,fileName]; sum += [self codeLinesWithPath:fullPath]; } return sum; }else{//文件 /* NSString *extension = [[path pathExtension] lowercaseString]; if (!([extension isEqualToString:@"h"] || [extension isEqualToString:@"m"] || [extension isEqualToString:@"mm"])) { return 0; } NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; NSArray *arr = [content componentsSeparatedByString:@"\n"]; return arr.count; */ NSString *extension = [[path pathExtension] lowercaseString]; if (!([extension isEqualToString:@"png"] || [extension isEqualToString:@"jpg"])) { return 0; } NSString *imageName = [path stringByReplacingOccurrencesOfString:@"/Users/xiaozeru/Desktop/HKProject/Res/" withString:@""]; NSData *data = [NSData dataWithContentsOfFile:path]; NSLog(@"imageName:%@--size:%dkb",imageName,data.length/1024); return 1; } return 0; }
标签:
原文地址:http://www.cnblogs.com/xiangli/p/4739019.html