[Cocos2dx Bug] [win32] Function CCFileUtils::fullPathFromRelativeFile forget consider the path separ

[Cocos2dx 2.2.4]windows

[win32平臺Bug]spa

const char* CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)code

方法中,沒有考慮windows下的 path separated is '\\'blog

源碼:get

1 const char* CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)
2 {
3     std::string relativeFile = pszRelativeFile;
4     CCString *pRet = CCString::create("");
5     pRet->m_sString = relativeFile.substr(0, relativeFile.rfind('/') + 1);
6     pRet->m_sString += getNewFilename(pszFilename);
7     return pRet->getCString();
8 }

修改成:源碼

 1 const char* CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)
 2 {
 3     std::string relativeFile = pszRelativeFile;
 4     CCString *pRet = CCString::create("");
 5 #if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
 6     pRet->m_sString = relativeFile.substr(0, relativeFile.rfind('\\') + 1);
 7 #else
 8     pRet->m_sString = relativeFile.substr(0, relativeFile.rfind('/') + 1);
 9 #endif
10     pRet->m_sString += getNewFilename(pszFilename);
11     return pRet->getCString();
12 }
相關文章
相關標籤/搜索