码迷,mamicode.com
首页 > 其他好文 > 详细

文件系统扫描的工具类

时间:2015-12-05 07:14:50      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

文件系统扫描的工具类

技术分享

 

说明

  • 递归扫描文件夹系统,并以树形结构组织起来
  • 支持沙盒、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

 

细节

技术分享

 

文件系统扫描的工具类

标签:

原文地址:http://www.cnblogs.com/YouXianMing/p/5020946.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!