[英]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. 我们有一个Mac桌面Moai应用程序,我们正在SFML上下文中加载该应用程序。 The app itself is sandboxed correctly as this in our host is returning a path in ~/Library/Containers :
应用本身已正确沙箱化,因为我们的主机在〜/ Library / Containers中返回路径:
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
However, when we print out MoaiEnvironment.documentDirectory, it is still returning the path ~/Documents. 但是,当我们打印出MoaiEnvironment.documentDirectory时,它仍返回路径〜/ Documents。 Looking at the Moai lib, it looks like it's setting the path with the exact same code:
看看Moai库,看起来它是使用完全相同的代码设置路径的:
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? 我们如何确保Moai二进制文件也设置为返回沙盒路径?
I ended up just creating a simple AKU extension similar to moaiext-ios, moaiext-osx: 我最终只是创建了一个简单的AKU扩展,类似于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()
. 我们现在将这个标头导入主机中,并调用
AKUMacOSXInit()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.