[Cocos2dx 2.2.4]

[win32平台Bug]

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

方法中,没有考虑windows下的 path separated is '\\'

源码:

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 }

 

相关文章:

  • 2022-12-23
  • 2021-10-06
  • 2021-11-24
  • 2021-04-16
  • 2022-12-23
  • 2021-06-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
相关资源
相似解决方案