1/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#import <UIKit/UIKit.h>
8#include "SkApplication.h"
9
10int main(int argc, char *argv[]) {
11    signal(SIGPIPE, SIG_IGN);
12    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
13    application_init();
14
15    // Identify the documents directory
16    NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
17    NSString *docsDir = [dirPaths objectAtIndex:0];
18    NSString *resourceDir = [docsDir stringByAppendingString:@"/resources"];
19    const char *d = [resourceDir UTF8String];
20
21    // change to the dcouments directory. To allow the 'writePath' flag to use relative paths.
22    NSFileManager *filemgr = [NSFileManager defaultManager];
23    int retVal = 99;
24    if ([filemgr changeCurrentDirectoryPath: docsDir] == YES)
25    {
26        IOS_launch_type launchType = set_cmd_line_args(argc, argv, d);
27        retVal = launchType == kApplication__iOSLaunchType
28                ? UIApplicationMain(argc, argv, nil, nil) : (int) launchType;
29    }
30    application_term();
31    [filemgr release];
32    [pool release];
33    return retVal;
34}
35