From b079cd89324e1a2aba143b16b51b5d5f4e188e84 Mon Sep 17 00:00:00 2001 From: u0u0 Date: Fri, 20 May 2022 17:53:52 +0800 Subject: [PATCH] mac writable path change to ~/Library/Application Support/BundleIdentifier --- cocos/platform/apple/CCFileUtils-apple.mm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cocos/platform/apple/CCFileUtils-apple.mm b/cocos/platform/apple/CCFileUtils-apple.mm index 843a34f..f9bb03e 100644 --- a/cocos/platform/apple/CCFileUtils-apple.mm +++ b/cocos/platform/apple/CCFileUtils-apple.mm @@ -250,11 +250,20 @@ std::string FileUtilsApple::getWritablePath() const return _writablePath; } - // save to document folder - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); +#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); // ~/Library/Application Support +#else + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); // ~/Document +#endif NSString *documentsDirectory = [paths objectAtIndex:0]; std::string strRet = [documentsDirectory UTF8String]; strRet.append("/"); +#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC + NSString* bundle = [[[NSBundle mainBundle]infoDictionary] objectForKey:@"CFBundleIdentifier"]; + strRet += [bundle UTF8String]; + strRet.append("/"); + createDirectory(strRet); // init directory +#endif return strRet; }