Sha256: d6ed530f06ead2d564c9bfacaafc1bddd51f58a031abb2132e24d95e7db8462f

Contents?: true

Size: 1.74 KB

Versions: 12

Compression:

Stored size: 1.74 KB

Contents

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

#import <Gosu/Directories.hpp>
#import <Foundation/Foundation.h>
#import <unistd.h>


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

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

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

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

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

#endif

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gosu-0.12.1 src/DirectoriesApple.cpp
gosu-0.12.0 src/DirectoriesApple.cpp
gosu-0.11.4.pre3 src/DirectoriesApple.cpp
gosu-0.11.4.pre2 src/DirectoriesApple.cpp
gosu-0.11.4.pre1 src/DirectoriesApple.cpp
gosu-0.11.3.1 src/DirectoriesApple.cpp
gosu-0.11.3 src/DirectoriesApple.cpp
gosu-0.11.3.pre1 src/DirectoriesApple.cpp
gosu-0.11.2 src/DirectoriesApple.cpp
gosu-0.11.1 src/DirectoriesApple.cpp
gosu-0.11.1.pre1 src/DirectoriesApple.cpp
gosu-0.11.0 src/DirectoriesApple.cpp