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 1038:f220d18c0615
prev1024:c67f2d61ab97
next1041:5fcc39857c5c
author nkeynes
date Thu Jun 25 01:15:25 2009 +0000 (13 years ago)
permissions -rw-r--r--
last change Move configuration to .lxdream/lxdreamrc on *nix, Library/Application Support/Lxdream on OS X
Create standard directories on first run
Add current quick state to config file
Refactor quick-state handling into dreamcast.c, and use the save directory
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * Cocoa builds need to use different paths from ordinary builds, since
     5  * the message catalogs, default config, etc are all bundle-relative.
     6  * Otherwise paths use the standard unix install paths
     7  *
     8  * Copyright (c) 2008 Nathan Keynes.
     9  *
    10  * This program is free software; you can redistribute it and/or modify
    11  * it under the terms of the GNU General Public License as published by
    12  * the Free Software Foundation; either version 2 of the License, or
    13  * (at your option) any later version.
    14  *
    15  * This program is distributed in the hope that it will be useful,
    16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  * GNU General Public License for more details.
    19  */
    21 #include <string.h>
    23 #include "lxdream.h"
    25 #include <AppKit/AppKit.h>
    27 static char *bundle_resource_path = NULL;
    28 static char *bundle_plugin_path = NULL;
    29 static char *user_data_path = NULL;
    31 static char *get_bundle_resource_path()
    32 {
    33     if( bundle_resource_path == NULL ) {
    34         NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    35         NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
    36         bundle_resource_path = strdup([resourcePath UTF8String]);
    37         [pool release];
    38     }
    39     return bundle_resource_path;    
    40 }
    42 const char *get_sysconf_path()
    43 {
    44     return get_bundle_resource_path();
    45 }
    47 const char *get_locale_path()
    48 {
    49     return get_bundle_resource_path();
    50 }
    52 const char *get_plugin_path()
    53 {
    54     if( bundle_plugin_path == NULL ) {
    55         NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    56         NSString *pluginPath = [[NSBundle mainBundle] builtInPlugInsPath];
    57         bundle_plugin_path = strdup([pluginPath UTF8String]);
    58         [pool release];
    59     }
    60     return bundle_plugin_path;    
    61 }
    64 const char *get_user_data_path()
    65 {
    66     if( user_data_path == NULL ) {
    67         char *home = getenv("HOME");
    68         user_data_path = g_strdup_printf( "%s/Library/Application Support/Lxdream", home );
    69     }
    70     return user_data_path;
    71 }
.