aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/iOSSampleApp/Shared/skia_ios.mm
blob: b8680c40e9c0f0ea5f53b5092c779bb33b3d28f4 (plain)
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
/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#import <UIKit/UIKit.h>
#include "SkApplication.h"

int main(int argc, char *argv[]) {
    signal(SIGPIPE, SIG_IGN);
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    application_init();

    // Identify the documents directory
    NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docsDir = [dirPaths objectAtIndex:0];
    NSString *resourceDir = [docsDir stringByAppendingString:@"/resources"];
    const char *d = [resourceDir UTF8String];

    // change to the dcouments directory. To allow the 'writePath' flag to use relative paths. 
    NSFileManager *filemgr = [NSFileManager defaultManager];
    int retVal = 99; 
    if ([filemgr changeCurrentDirectoryPath: docsDir] == YES)
    {
        IOS_launch_type launchType = set_cmd_line_args(argc, argv, d);
        retVal = launchType == kApplication__iOSLaunchType
                ? UIApplicationMain(argc, argv, nil, nil) : (int) launchType;
    }
    application_term();
    [filemgr release];
    [pool release];
    return retVal;
}