Skip to content
This repository was archived by the owner on Jul 24, 2019. It is now read-only.

create output directory automatically #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 19 additions & 2 deletions cartool/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down