1 ///////////////////////////////////////////////////////////////////////////
4 // Updated: 19-Jul-1998
6 // Copyright: Ferdinand Prantl
7 // E-mail: prantl@ff.cuni.cz
9 // Some handy stuff to deal with files and their names
11 // You are free to use or modify this code to the following restrictions:
12 // - Acknowledge me somewhere in your about box, simple "Parts of code by.."
13 // will be enough. If you can't (or don't want to), contact me personally.
14 // - LEAVE THIS HEADER INTACT
15 ////////////////////////////////////////////////////////////////////////////
20 ////////////////////////////////////////////////////////////////////////////////
22 int GetExtPosition (const tchar_t* pszString)
24 if (pszString == nullptr || !*pszString)
26 const std::basic_string<tchar_t> sString = pszString;
27 int len = static_cast<int>(sString.length ()), posit = len;
30 if ((test = sString.at (--posit)) == _T ('.'))
33 while (posit && test != _T ('\\') && test != _T (':'));
35 while (posit && (test != _T ('\\') || _ismbstrail((unsigned char *)pszString, (unsigned char *)pszString + posit)) && test != _T (':'));
40 std::basic_string<tchar_t> GetExt (const std::basic_string<tchar_t>& sString)
42 std::basic_string<tchar_t> sString2 = sString;
43 if (!sString2.empty ())
45 sString2 = sString2.substr (GetExtPosition (sString2.c_str ()));
46 if (!sString2.empty () && sString2[0] == _T ('.'))
48 sString2 = sString2.substr (1);
54 ////////////////////////////////////////////////////////////////////////////////