typeoneerror
typeoneerror

Reputation: 56968

Correct Documents Path with Sandboxed Mac application using MOAI

We have a Mac desktop Moai app that we are loading up inside an SFML context. The app itself is sandboxed correctly as this in our host is returning a path in ~/Library/Containers:

NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

However, when we print out MoaiEnvironment.documentDirectory, it is still returning the path ~/Documents. Looking at the Moai lib, it looks like it's setting the path with the exact same code:

environment.SetValue ( MOAI_ENV_documentDirectory,  [[ NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory, NSUserDomainMask, YES ) objectAtIndex:0 ] UTF8String ]);

How do we ensure the Moai binaries are set up to return the sandboxed path as well?

Upvotes: 1

Views: 136

Answers (1)

typeoneerror
typeoneerror

Reputation: 56968

I ended up just creating a simple AKU extension similar to moaiext-ios, moaiext-osx:

// aku/AKU-macosx.h

#ifndef AKU_MACOSX_H
#define AKU_MACOSX_H

#import <Foundation/Foundation.h>

void AKUMacOSXInit ();

#endif

// aku/AKU-macosx.mm

#import <aku/AKU-macosx.h>

#include <moaicore/moaicore.h>

void AKUMacOSXInit () {

    MOAIEnvironment& environment = MOAIEnvironment::Get ();

    environment.SetValue ( MOAI_ENV_cacheDirectory, [ [ NSSearchPathForDirectoriesInDomains ( NSCachesDirectory, NSUserDomainMask, YES ) objectAtIndex:0 ] UTF8String ]);
    environment.SetValue ( MOAI_ENV_documentDirectory, [ [ NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory, NSUserDomainMask, YES ) objectAtIndex:0 ] UTF8String ]);

}

We just import this header in our host now and call AKUMacOSXInit().

Upvotes: 1

Related Questions