没有权限保存文件

问题描述 投票:0回答:1

最近我使用的是cocos 2d-x ver-3.17。

我将资源编译为jsc然后使服务器上传它像update-server,我认为控制版本。现在,当我在IOS中构建应用程序,它将连接到更新服务器,然后下载文件jsc。不幸的是,当应用程序试图保存文件时,它会落到错误“没有权限保存文件”。我该怎么做才能为他们提供解决问题的许可。

无法创建目录:“/ var / mobile / Containers / Data / Application / C9BA91B9-AEF6-4FF8-B5F3-061AF15441A5 / Documents_temp /”:您无权将文件“Documents_temp”保存在“C9BA91B9-”文件夹中AEF6-4FF8-B5F3-061AF15441A5” 。

bool FileUtilsApple::createDirectory(const std::string& path)
{
    CCASSERT(!path.empty(), "Invalid path");

    if (isDirectoryExist(path))
        return true;

    NSError* error;

    bool result = [s_fileManager createDirectoryAtPath:[NSString stringWithUTF8String:path.c_str()] withIntermediateDirectories:YES attributes:nil error:&error];

    if(!result && error != nil)
    {
        CCLOGERROR("Fail to create directory \"%s\": %s", path.c_str(), [error.localizedDescription UTF8String]);
    }

    return result;
}

我怎样才能获得保存文件的权限?

objective-c cocos2d-x
1个回答
0
投票

解决了:https://forum.cocos.com/t/topic/47298/3自力更生,找出问题所在,需要定义文件目录

找到你的initAssetManager:

var storagePath = (jsb.fileUtils ? jsb.fileUtils.getWritablePath() : "./")+"temp/";
© www.soinside.com 2019 - 2024. All rights reserved.