-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOCUtilities.m
80 lines (59 loc) · 2.05 KB
/
OCUtilities.m
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// OCUtilities.m
// OverClouded
//
// Created by Parag Dulam on 18/11/14.
// Copyright (c) 2014 Parag Dulam. All rights reserved.
//
#import "OCUtilities.h"
@implementation OCUtilities
+(NSString *) getUUID
{
return [[NSUUID UUID] UUIDString];
}
+(NSString *) getLibraryPath
{
NSString* path = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
return path;
}
+(NSString *) getAppCachePath
{
return [NSString stringWithFormat:@"%@/app_cache",[[self class] getLibraryPath]];
}
+(NSString *) getAccountsPath
{
return [NSString stringWithFormat:@"%@/accounts",[[self class] getAppCachePath]];
}
+(NSString *) getAccountsDBPath {
return [NSString stringWithFormat:@"%@/accounts.db",[[self class] getAccountsPath]];
}
+(BOOL) doesFileExistAtPath:(NSString *) path {
return [[NSFileManager defaultManager] fileExistsAtPath:path];
}
+(BOOL) doesAccountsFolderExist {
return [[self class] doesFileExistAtPath:[[self class] getAccountsPath]];
}
+(void) createFileAtPath:(NSString *)path
completionHandler:(void(^)(NSError *error))completionBlock {
NSError *error = nil;
[[NSFileManager defaultManager] createFileAtPath:path
contents:nil
attributes:nil];
completionBlock(error);
}
+(void) createFolderAtPath:(NSString *)path
completionHandler:(void(^)(NSError *error))completionBlock {
NSError *error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:path
withIntermediateDirectories:YES
attributes:nil
error:&error];
completionBlock(error);
}
+(void) createAccountsFolder:(void(^)(NSError *error))completionBlock {
NSString *accountspath = [[self class] getAccountsPath];
NSLog(@"accountspath %@",accountspath);
[[self class] createFolderAtPath:accountspath
completionHandler:completionBlock];
}
@end