TSTRING GetFileFromPath(CTSTRING &tsPath) { TSTRING::size_type r = tsPath.rfind(_T('\\')); if (TSTRING::npos != r) { return tsPath.substr(r + 1); } else if (TSTRING::npos != (r = tsPath.rfind(_T('/')))) { return tsPath.substr(r + 1); } return _T(""); }
TSTRING GetPathFromFile(CTSTRING &tsFile) { TSTRING::size_type r = tsFile.rfind(_T('\\')); if (TSTRING::npos != r) { return tsFile.substr(0, r + 1); } else if (TSTRING::npos != (r = tsFile.rfind(_T('/')))) { return tsFile.substr(0, r + 1); } return _T(""); }
void GetShortFileName(CTSTRING &tsFile, TSTRING &tsOut) { if (_T("") != tsFile) { TSTRING::size_type n = tsFile.rfind(_T('\\')); if (TSTRING::npos != n) { tsOut = tsFile.substr(n + 1); } else { tsOut = tsFile; } } }
bool GetFileExtension(CTSTRING &tsFile, TSTRING &tsOut) { bool r = false; if (_T("") != tsFile) { TSTRING::size_type n = tsFile.rfind(_T('.')); if (TSTRING::npos != n) { tsOut = tsFile.substr(n + 1); r = true; } } return r; }