文件系统扫描的工具类

来源:互联网 发布:工作流管理系统源码 编辑:程序博客网 时间:2024/06/07 08:28

文件系统扫描的工具类

 

说明

  • 递归扫描文件夹系统,并以树形结构组织起来
  • 支持沙盒、bundle扫描
  • 支持扫描深度设置
  • 用File对象表示一个扫描出来的文件,File对象包含了一个文件或者文件夹的基本文件信息(如文件名字,是否隐藏,文件扩展名,文件url地址等等),便于后续操作

源码

https://github.com/YouXianMing/FileManager

复制代码
////  ViewController.m//  FileManager////  Created by YouXianMing on 15/11/19.//  Copyright © 2015年 YouXianMing. All rights reserved.//#import "ViewController.h"#import "FileManager.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad {        [super viewDidLoad];        // Scan files.    File *file = [FileManager scanRelatedFilePath:@"~/Library" maxTreeLevel:1];    NSLog(@"\n\n%@ \n%@\n\n", file, file.subFiles);        // Get the real file path from related file path.    NSLog(@"%@", [FileManager theRealFilePath:@"~/Documents"]);    NSLog(@"%@", [FileManager theRealFilePath:@"-"]);        // Check the file at the given path exist or not.    NSLog(@"%d", [FileManager fileExistWithRealFilePath:[FileManager theRealFilePath:@"~/Library/Caches"]]);    NSLog(@"%d", [FileManager fileExistWithRealFilePath:[FileManager theRealFilePath:@"~/YouXianMing"]]);}@end
复制代码

 

细节

 


posted @ 2015-12-05 06:49 YouXianMing 阅读(88) 评论(2)  编辑 收藏

1 0