Search
lxdream.org :: lxdream/src/cocoaui/paths_osx.m
lxdream 0.9.1
released Jun 29
Download Now
filename src/cocoaui/paths_osx.m
changeset 1024:c67f2d61ab97
prev1021:848db285a184
next1038:f220d18c0615
author nkeynes
date Sat Jun 13 00:50:48 2009 +0000 (13 years ago)
permissions -rw-r--r--
last change Build drivers with library dependencies as shared objects (ie plugins)
file annotate diff log raw
nkeynes@965
     1
/**
nkeynes@1021
     2
 * $Id$
nkeynes@965
     3
 *
nkeynes@965
     4
 * Cocoa builds need to use different paths from ordinary builds, since
nkeynes@965
     5
 * the message catalogs, default config, etc are all bundle-relative.
nkeynes@965
     6
 * Otherwise paths use the standard unix install paths
nkeynes@965
     7
 *
nkeynes@965
     8
 * Copyright (c) 2008 Nathan Keynes.
nkeynes@965
     9
 *
nkeynes@965
    10
 * This program is free software; you can redistribute it and/or modify
nkeynes@965
    11
 * it under the terms of the GNU General Public License as published by
nkeynes@965
    12
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@965
    13
 * (at your option) any later version.
nkeynes@965
    14
 *
nkeynes@965
    15
 * This program is distributed in the hope that it will be useful,
nkeynes@965
    16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@965
    17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@965
    18
 * GNU General Public License for more details.
nkeynes@965
    19
 */
nkeynes@965
    20
nkeynes@965
    21
#include <string.h>
nkeynes@965
    22
nkeynes@965
    23
#include "lxdream.h"
nkeynes@965
    24
nkeynes@965
    25
#include <AppKit/AppKit.h>
nkeynes@965
    26
nkeynes@965
    27
static char *bundle_resource_path = NULL;
nkeynes@1024
    28
static char *bundle_plugin_path = NULL;
nkeynes@965
    29
nkeynes@965
    30
static char *get_bundle_resource_path()
nkeynes@965
    31
{
nkeynes@965
    32
    if( bundle_resource_path == NULL ) {
nkeynes@965
    33
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
nkeynes@965
    34
        NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
nkeynes@965
    35
        bundle_resource_path = strdup([resourcePath UTF8String]);
nkeynes@965
    36
        [pool release];
nkeynes@965
    37
    }
nkeynes@965
    38
    return bundle_resource_path;    
nkeynes@965
    39
}
nkeynes@965
    40
nkeynes@965
    41
const char *get_sysconf_path()
nkeynes@965
    42
{
nkeynes@965
    43
    return get_bundle_resource_path();
nkeynes@965
    44
}
nkeynes@965
    45
nkeynes@965
    46
const char *get_locale_path()
nkeynes@965
    47
{
nkeynes@965
    48
    return get_bundle_resource_path();
nkeynes@965
    49
}
nkeynes@965
    50
nkeynes@1024
    51
const char *get_plugin_path()
nkeynes@1024
    52
{
nkeynes@1024
    53
    if( bundle_plugin_path == NULL ) {
nkeynes@1024
    54
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
nkeynes@1024
    55
        NSString *pluginPath = [[NSBundle mainBundle] builtInPlugInsPath];
nkeynes@1024
    56
        bundle_plugin_path = strdup([pluginPath UTF8String]);
nkeynes@1024
    57
        [pool release];
nkeynes@1024
    58
    }
nkeynes@1024
    59
    return bundle_plugin_path;    
nkeynes@1024
    60
}
.