-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommon.m
More file actions
36 lines (30 loc) · 1.05 KB
/
Copy pathCommon.m
File metadata and controls
36 lines (30 loc) · 1.05 KB
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
//
// Common.m
// Kurs
//
// Created by Mustafin Askar on 17.06.13.
// Copyright (c) 2013 askar. All rights reserved.
//
#import "Common.h"
@implementation Common
+ (NSString *)getPathOfCopiedFile:(NSString *)file withType:(NSString *)type
{
NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsDir = [dirPaths objectAtIndex:0];
NSString *storePath = [[NSString alloc] initWithString:[docsDir stringByAppendingPathComponent: [NSString stringWithFormat:@"%@.%@", file, type]]];
NSError *error;
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:storePath])
{
NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:file ofType:type];
if (defaultStorePath)
{
if ([fileManager fileExistsAtPath:defaultStorePath])
{
[fileManager copyItemAtPath:defaultStorePath toPath:storePath error:&error];
}
}
}
return storePath;
}
@end