Files
yinmeng-ios/xplan-ios/Base/Tool/File/CommonFileUtils.h
2022-03-10 18:55:18 +08:00

92 lines
2.0 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// CommonFileUtils.h
// Commons
//
// Created by 小城 on 14-6-5.
// Copyright (c) 2014年 YY Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface CommonFileUtils : NSObject
/**Some FilePaths
*/
+ (NSString *)documentsDirectory;
+ (NSString *)cachesDirectory;
/**
* File Operation
*/
/**
* 创建文件所在的目录
*
* @param path 文件的绝对路径
*
* @return 是否创建成功
*/
+ (BOOL)createDirForPath:(NSString *)path;
/**
* 创建目录
*
* @param dirPath 目录绝对路径
*
* @return 是否创建成功
*/
+ (BOOL)createDirWithDirPath:(NSString *)dirPath;
/**
* 删除文件
*
* @param path 文件所在的绝对路径
*
* @return 是否删除成功
*/
+ (BOOL)deleteFileWithFullPath:(NSString *)path;
/**
* 指定路径的文件是否存在
*
* @param filePath 文件的绝对路径
*
* @return 是否存在
*/
+ (BOOL)isFileExists:(NSString *)filePath;
/**
* 在文件的末尾追加文本内容
*
* @param content 文本内容
* @param filePath 文件绝对路径比如保证该文件是存在的返回会返回NO
*
* @return 是否追加成功
*/
+ (BOOL)appendContent:(NSString *)content toFilePath:(NSString *)filePath;
/**FileUtils In UserDefault
*/
+ (BOOL)writeObject:(id)object toUserDefaultWithKey:(NSString*)key;
+ (id)readObjectFromUserDefaultWithKey:(NSString*)key;
+ (BOOL)deleteObjectFromUserDefaultWithKey:(NSString*)key;
/**FileUtils In CachesPath
*/
+ (void)writeObject:(id)object toCachesPath:(NSString*)path;
+ (id)readObjectFromCachesPath:(NSString*)path;
+ (BOOL)deleteFileFromCachesPath:(NSString *)path;
/**FileUtils In DocumentPath
*/
+ (void)writeObject:(id)object toDocumentPath:(NSString *)path;
+ (id)readObjectFromDocumentPath:(NSString *)path;
+ (BOOL)deleteFileFromDocumentPath:(NSString *)path;
+ (BOOL)copyItem:(NSString *)destination toPath:(NSString *)toPath;
+ (NSString*)getFileMD5WithPath:(NSString*)path;
@end