Created
January 16, 2014 08:46
-
-
Save weekwood/8451702 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSFileManager *fileManager = [NSFileManager defaultManager]; | |
NSError *error; | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *documentsDirectory = [paths objectAtIndex:0]; | |
NSString *documentDBFolderPath = [documentsDirectory stringByAppendingPathComponent:@"templates"]; | |
NSString *resourceDBFolderPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"templates"]; | |
if (![fileManager fileExistsAtPath:documentDBFolderPath]) { | |
//Create Directory! | |
[fileManager createDirectoryAtPath:documentDBFolderPath withIntermediateDirectories:NO attributes:nil error:&error]; | |
} else { | |
} | |
NSArray *fileList = [fileManager contentsOfDirectoryAtPath:resourceDBFolderPath error:&error]; | |
for (NSString *s in fileList) { | |
NSString *newFilePath = [documentDBFolderPath stringByAppendingPathComponent:s]; | |
NSString *oldFilePath = [resourceDBFolderPath stringByAppendingPathComponent:s]; | |
if (![fileManager fileExistsAtPath:newFilePath]) { | |
//File does not exist, copy it | |
[fileManager copyItemAtPath:oldFilePath toPath:newFilePath error:&error]; | |
if([s isEqualToString:@"catalog.yml"]){ | |
NSFileManager *fileManager = [NSFileManager defaultManager]; | |
NSData *data = [fileManager contentsAtPath:[NSString stringWithFormat:@"%@/catalog.yml",documentDBFolderPath]]; | |
NSError *err; | |
id yaml = [YAMLSerialization YAMLWithData:data options:kYAMLReadOptionStringScalars error:&err]; | |
NSString *filePath = [documentDBFolderPath | |
stringByAppendingPathComponent:@"catalog.plist"]; | |
[yaml writeToFile:filePath atomically:YES]; | |
} | |
} else { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment