Cocos2d-x How to get path file
const char* Global::bundlePath(const char* fileName) {
string filePath = CCFileUtils::sharedFileUtils()->fullPathForFilename(fileName);
CCString *pRet = CCString::create("");
pRet->m_sString = filePath;
return pRet->getCString();
}
const char* Global::documentsPath(const char*folder ,const char* fileName) {
string filePath;
if(strlen(folder) == 0) {
filePath = CCFileUtils::sharedFileUtils()->getWritablePath() + fileName;
} else {
filePath = CCFileUtils::sharedFileUtils()->getWritablePath() + folder + "/" + fileName;
}
CCString *pRet = CCString::create("");
pRet->m_sString = filePath;
return pRet->getCString();
}
string filePath = CCFileUtils::sharedFileUtils()->fullPathForFilename(fileName);
CCString *pRet = CCString::create("");
pRet->m_sString = filePath;
return pRet->getCString();
}
const char* Global::documentsPath(const char*folder ,const char* fileName) {
string filePath;
if(strlen(folder) == 0) {
filePath = CCFileUtils::sharedFileUtils()->getWritablePath() + fileName;
} else {
filePath = CCFileUtils::sharedFileUtils()->getWritablePath() + folder + "/" + fileName;
}
CCString *pRet = CCString::create("");
pRet->m_sString = filePath;
return pRet->getCString();
}
Comments
Post a Comment