-
Notifications
You must be signed in to change notification settings - Fork 1
/
FileUtils.h
34 lines (27 loc) · 1.07 KB
/
FileUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
* FileUtils.h
* iOS Helpers
*
* Created by Sergej Tatarincev on 01.11.10.
* Copyright 2010 GoodNamesAreTaken. All rights reserved.
*
*/
#ifndef FILE_UTILS_H
#define FILE_UTILS_H
inline static NSString* filePathInDirectory(NSString* fileName, NSSearchPathDirectory directory) {
NSArray* paths = NSSearchPathForDirectoriesInDomains(directory, NSUserDomainMask, YES);
return [[paths objectAtIndex:0] stringByAppendingPathComponent:fileName];
}
inline static NSString* documentsFilePath(NSString* fileName) {
return filePathInDirectory(fileName, NSDocumentDirectory);
}
inline static NSString* cachesFilePath(NSString* fileName) {
return filePathInDirectory(fileName, NSCachesDirectory);
}
inline static NSString* bundlePath(NSString* fileName) {
return [[NSBundle mainBundle] pathForResource:[fileName stringByDeletingPathExtension] ofType:[fileName pathExtension]];
}
inline static BOOL createDirectory(NSString* dirName) {
return [[NSFileManager defaultManager] createDirectoryAtPath:dirName withIntermediateDirectories:YES attributes:nil error:nil];
}
#endif