删除路径最后一部分

比如 “a/b/c/1234.png” 就是删除/1234.png

查找反斜扛,再左截取

这里是一个string split的sample。

http://www.cplusplus.com/reference/string/string/find_last_of/

谢谢楼上两位 自己重写了个
在CCString.cpp里添加
CCString* CCString::stringByDeletingPathExtension()
{
//CCLOG("----------getCString = %s", getCString());
std::string path = getCString();
int n = path.find_last_of(’.’);
if (n == -1)
{
//没有“/”号的时候将字符串置空
m_sString = “”;
}
else
{
m_sString = path.substr(0, n);
}

return CCString::create(m_sString);

}