Reputation: 147
I'm new to cocos2d-x and while compiling my project I get this error.
Call to unavailable function 'system': not available on iOS
I see this call is no longer applicable but, what can I use to replace it? Any insight would be appreciated!
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
}
Upvotes: 4
Views: 8221
Reputation: 11
I have not confirmed this, but you might try something like the following:
// 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);
}
Upvotes: 0
Reputation: 65
system function is not available on iOS 11 Use this mean while until Oct 9 we can have new cocos2d-x 3.16
if (command.size() >= 0)
Upvotes: 2