From 674b90730b8f4f97f9fe0ebaccac21b165412f8a Mon Sep 17 00:00:00 2001 From: Aaron Lewis Date: Wed, 15 Jun 2016 10:04:14 +0800 Subject: [PATCH 1/2] Let us release that way --- cartool/main.m | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/cartool/main.m b/cartool/main.m index 4ad7da6..7890930 100644 --- a/cartool/main.m +++ b/cartool/main.m @@ -60,12 +60,29 @@ void CGImageWriteToFile(CGImageRef image, NSString *path) CFRelease(destination); } - void exportCarFileAtPath(NSString * carPath, NSString *outputDirectoryPath) { NSError *error = nil; - + BOOL isDir; + NSFileManager *fileManager = [NSFileManager defaultManager]; + outputDirectoryPath = [outputDirectoryPath stringByExpandingTildeInPath]; + + // mkdir + if ([fileManager fileExistsAtPath:outputDirectoryPath isDirectory:&isDir]) { + if (! isDir) { + NSLog(@"Error: output directory %@ exists and is not a directory", outputDirectoryPath); + exit(1); + } + } else { + if (![fileManager createDirectoryAtPath:outputDirectoryPath + withIntermediateDirectories:NO + attributes:nil + error:&error]) + { + NSLog(@"Error: %@ while trying to create directory %@", error, outputDirectoryPath); + } + } CUIThemeFacet *facet = [CUIThemeFacet themeWithContentsOfURL:[NSURL fileURLWithPath:carPath] error:&error]; From c858d6ca718cf21b88e4fc0b23fc2400c6a66829 Mon Sep 17 00:00:00 2001 From: Aaron Lewis Date: Wed, 15 Jun 2016 10:09:11 +0800 Subject: [PATCH 2/2] Let us release that way --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 0879841..a977714 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,8 @@ cartool ======= Export images from OS X / iOS .car CoreUI archives. Very rough code, probably tons wrong with it, but still useful. + +changelog +======= + +2016.06.15 create output directory automatically, otherwise it raises a segfault error \ No newline at end of file