bool SplitFilenameString_Priv (const char* pFilename, const size_t Length, CSString& Path, CSString& BaseFilename, CSString& Extension) { const char* pParse = pFilename; int Index = Length - 1; int ExtensionIndex; Extension.Empty(); BaseFilename.Empty(); Path.Empty(); if (Length == 0) return true; while (Index >= 0) { if (pParse[Index] == '.') { Extension = pParse + Index + 1; ExtensionIndex = Index; break; } else if (pParse[Index] == '\\' || pParse[Index] == '/' || pParse[Index] == ':') { ExtensionIndex = Length; Extension.Empty(); break; } --Index; } while (Index >= 0) { if (pParse[Index] == '\\' || pParse[Index] == '/' || pParse[Index] == ':') { BaseFilename = pParse + Index + 1; BaseFilename.Truncate(ExtensionIndex - Index - 1); Path.Copy(pFilename, Index + 1); return true; } --Index; } BaseFilename.Copy(pFilename, ExtensionIndex - Index - 1); return true; }
void RemoveExtensionString(CSString& Filename) { const char* pParse = Filename.c_str(); int Index = Filename.GetLength() - 1; while (Index >= 0) { if (pParse[Index] == '.') { Filename.Truncate(Index); return; } else if (pParse[Index] == '\\' || pParse[Index] == '/' || pParse[Index] == ':') { return; } --Index; } }