How can create folder at iphone by cocos2d?
thanks!
I have not create folder at iphone, but I have created files at it.
What problem did you meet? May be your path is wrong.
Hey guys,
I’m having problem creating a directory as well.
I’m trying
@
string command = string(“mkdir”)+ writablePath + string(filename);
system(command.c_str());
@
Getting this error
mkdir: Simulator/5.1/Applications/2A4B81C0-3DE9-4724-9850-5E77270D90AB/Library/Caches: No such file or directory
might need to escape the writablePath
“iPhone/ Simulator”
but anyway, what is the recommended way to create a directory, that would work cross platform?
thanks
Hi,
Any idea to create a folder?
thanks
Hi,
I add this method in CCFileUtils to create a folder on iOS:
bool CCFileUtils::createDirectoryInPath(char *pDirectoryName)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *newPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithUTF8String:pDirectoryName]];
if (![[NSFileManager defaultManager] fileExistsAtPath:newPath])
{
NSError* error;
if( [[NSFileManager defaultManager] createDirectoryAtPath:newPath withIntermediateDirectories:NO attributes:nil error:&error])
return true;
else
return false;
}
return false;
}