From dae0b690f796bd421ab69a0219cb1b46095b9f27 Mon Sep 17 00:00:00 2001 From: Zezula Ladislav Date: Wed, 8 Nov 2017 15:31:45 +0100 Subject: + SFileAddListFile and SFileCompactArchive now take "const TCHAR *" instead of "const char *" + Fixed some bugs --- src/StormCommon.h | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/StormCommon.h') diff --git a/src/StormCommon.h b/src/StormCommon.h index 868f1c1..95b72a3 100644 --- a/src/StormCommon.h +++ b/src/StormCommon.h @@ -133,11 +133,15 @@ extern unsigned char AsciiToUpperTable[256]; //----------------------------------------------------------------------------- // Safe string functions -void StringCopyA(char * dest, const char * src, size_t nMaxChars); -void StringCatA(char * dest, const char * src, size_t nMaxChars); - -void StringCopyT(TCHAR * dest, const TCHAR * src, size_t nMaxChars); -void StringCatT(TCHAR * dest, const TCHAR * src, size_t nMaxChars); +void StringCopy(char * szTarget, size_t cchTarget, const char * szSource); +void StringCat(char * szTarget, size_t cchTargetMax, const char * szSource); + +#ifdef _UNICODE +void StringCopy(TCHAR * szTarget, size_t cchTarget, const char * szSource); +void StringCopy(char * szTarget, size_t cchTarget, const TCHAR * szSource); +void StringCopy(TCHAR * szTarget, size_t cchTarget, const TCHAR * szSource); +void StringCat(TCHAR * szTarget, size_t cchTargetMax, const TCHAR * szSource); +#endif //----------------------------------------------------------------------------- // Encryption and decryption functions @@ -296,11 +300,20 @@ void Patch_Finalize(TMPQPatcher * pPatcher); bool CheckWildCard(const char * szString, const char * szWildCard); bool IsInternalMpqFileName(const char * szFileName); -const TCHAR * GetPlainFileName(const TCHAR * szFileName); -const char * GetPlainFileName(const char * szFileName); +template +const XCHAR * GetPlainFileName(const XCHAR * szFileName) +{ + const XCHAR * szPlainName = szFileName; + + while(*szFileName != 0) + { + if(*szFileName == '\\' || *szFileName == '/') + szPlainName = szFileName + 1; + szFileName++; + } -void CopyFileName(TCHAR * szTarget, const char * szSource, size_t cchLength); -void CopyFileName(char * szTarget, const TCHAR * szSource, size_t cchLength); + return szPlainName; +} //----------------------------------------------------------------------------- // Internal support for MPQ modifications -- cgit v1.2.3