调用不可用的函数“系统”:在 iOS 上不可用

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

我是 cocos2d-x 的新手,在编译我的项目时出现此错误。

调用不可用的功能“系统”:在 iOS 上不可用

我看到这个调用不再适用,但是我可以用什么来代替它? 任何见解将不胜感激!

bool FileUtils::removeDirectory(const std::string& path)
{
#if !defined(CC_TARGET_OS_TVOS)
    std::string command = "rm -r ";
    // Path may include space.
    command += "\"" + path + "\"";
    if (system(command.c_str()) >= 0) /*System Call Error/Not Availible*/
        return true;
    else
        return false;
 #else
    return false;
#endif
}
c++ cocos2d-x
3个回答
2
投票

system
功能在 iOS 11 上不可用,针对同一问题有一个已接受的 PR

现在我们使用

nftw
而不是
system
。 使用 cocos2d-x 存储库的
v3
分支更新您的源代码。


2
投票

系统功能在iOS 11上不可用 利用这个时间直到 10 月 9 日我们就可以拥有新的 cocos2d-x 3.16

if (命令.size() >= 0)


0
投票

我还没有证实这一点,但你可以尝试如下:

//  This is ugly, but it should work
if (fork() == 0)
{
    string fullpath = "\"" + _storagePath + "\"";
    string arg1 = "-r";
    char* args[] =
    {
        &arg1.at(0),
        &fullpath.at(0),
        nullptr,
    };
    const char* command = "rd";
    execvp(command, args);
}
© www.soinside.com 2019 - 2024. All rights reserved.