Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
FileUtils::removeFile doesn't work iOS #8568
In Cocos2d-x 3.3beta0
The FileUtils::removeFile doesn't seem to work. It generates the correct command but it doesn't seem to do anything. Perhaps it has to do with this Stack Overflow post? http://stackoverflow.com/questions/11291164/system-command-not-working-when-enabling-app-sandboxing
"rm -f "/Users/my_user/Library/Developer/CoreSimulator/Devices/2821C4FC-9316-4183-A3A9-62E19BAE4A65/data/Containers/Data/Application/FEDDBD50-526B-4C88-A58B-816190CE6A47/Documents/db.sqlite""
@Dhilan007 I just tested it again and it's not working in the simulator or on my devices. It is working on Android. Here are some more details:
iOS 8 - iPhone 6 simulator - Xcode 6.0.1
iOS 7.1.2 - iPhone 5 device - Xcode 6.0.1
Android 4.4.2 Device
I'm creating the path like so:
My copyFile code and reading the file works so the path should be correct. Also, the removeFile is still returning true even when the file sin't deleted.
@Dhilan007 The exit code I'm seeing on iOS is 5 whereas in Android it is 0. The code that checks the exit code is:
if (system(command.c_str()) >= 0) // an exit code > 0 means an error occurred
it should be:
if (system(command.c_str()) == 0) // exit(0) means success
The same check is used for removeDirectory, it should also be fixed at least for systems running on unix or linux.
I'm still unsure why the command is not succeeding on iOS for me. For now, I've changed the code to use std::remove, which works on iOS, simulator and Android
bool FileUtils::removeFile(const std::string &path)