typedef std::basic_string<TCHAR> tstring;
tstring ExtractStringWithDelim(LPCTSTR dump, const TCHAR delim, bool isLast)
{
if(!dump) { return _T(""); }
tstring ret(dump);
size_t pos = ret.rfind(delim);
if(pos != tstring::npos) {
if(isLast) {
ret = ret.substr(pos+1, ret.length());
}
else {
ret = ret.substr(0, pos);
}
}
return ret;
}
tstring ExtractPathFromUrl(LPCTSTR path)
{
return ExtractStringWithDelim(path, _T('/'), false);
}
tstring ExtractFilenameFromUrl(LPCTSTR path)
{
return ExtractStringWithDelim(path, _T('/'), true);
}
tstring ExtractPathFromFullPath(LPCTSTR path)
{
return ExtractStringWithDelim(path, _T('\\'), false);
}
tstring ExtractFilenameFromFullPath(LPCTSTR path)
{
return ExtractStringWithDelim(path, _T('\\'), true);
}