Sha256: 196c72275c5e0ac86698c852c42676120f4029100a9e1dcce08eeb53f33afea9

Contents?: true

Size: 1.7 KB

Versions: 26

Compression:

Stored size: 1.7 KB

Contents

#include <Gosu/Platform.hpp>
#if defined(GOSU_IS_MAC)

#import <Gosu/Directories.hpp>
#import <Foundation/Foundation.h>
#import <unistd.h>
using namespace std;

void Gosu::use_resource_directory()
{
    chdir(resource_prefix().c_str());
}

string Gosu::user_settings_prefix()
{
    static string result = [] {
        @autoreleasepool {
            NSString* library =
                NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)[0];
            NSString* preferences = [library stringByAppendingPathComponent:@"Preferences"];
            
            return string(preferences.UTF8String ?: ".") + "/";
        }
    }();
    return result;
}

string Gosu::user_documents_prefix()
{
    static string result = [] {
        @autoreleasepool {
            NSString* documents =
                NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
            
            return string(documents.UTF8String ?: ".") + "/";
        }
    }();
    return result;
}

string Gosu::resource_prefix()
{
    static string result = [] {
        @autoreleasepool {
            NSString* resources = [NSBundle mainBundle].resourcePath;
            return string(resources.UTF8String ?: ".") + "/";
        }
    }();
    return result;
}

string Gosu::shared_resource_prefix()
{
    #ifdef GOSU_IS_IPHONE
    return resource_prefix();
    #else
    static string result = [] {
        @autoreleasepool {
            NSString* bundle_path = [NSBundle mainBundle].bundlePath;
            NSString* containing_path = [bundle_path stringByDeletingLastPathComponent];
            return string(containing_path.UTF8String ?: ".");
        }
    }();
    return result;
    #endif
}

#endif

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
gosu-1.4.1 src/DirectoriesApple.cpp
gosu-1.4.0 src/DirectoriesApple.cpp
gosu-1.3.0 src/DirectoriesApple.cpp
gosu-1.2.0 src/DirectoriesApple.cpp
gosu-1.1.1.1 src/DirectoriesApple.cpp
gosu-1.1.0 src/DirectoriesApple.cpp
gosu-1.1.0.pre2 src/DirectoriesApple.cpp
gosu-1.1.0.pre1 src/DirectoriesApple.cpp
gosu-1.0.0 src/DirectoriesApple.cpp
gosu-1.0.0.pre2 src/DirectoriesApple.cpp
gosu-1.0.0.pre1 src/DirectoriesApple.cpp
gosu-0.15.2 src/DirectoriesApple.cpp
gosu-0.15.1 src/DirectoriesApple.cpp
gosu-0.15.0 src/DirectoriesApple.cpp
gosu-0.14.6.pre1 src/DirectoriesApple.cpp
gosu-0.14.5 src/DirectoriesApple.cpp
gosu-0.14.4 src/DirectoriesApple.cpp
gosu-0.14.4.pre2 src/DirectoriesApple.cpp
gosu-0.14.3.pre1 src/DirectoriesApple.cpp
gosu-0.14.3 src/DirectoriesApple.cpp