From 72d2a5ac9441219bff4abdef611302f611d077a0 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Mon, 28 May 2012 09:15:46 +0000 Subject: A few changes to make this compile --- Datafile/Datafile.vcxproj | 1 + Datafile/Main.cpp | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'Datafile') diff --git a/Datafile/Datafile.vcxproj b/Datafile/Datafile.vcxproj index 3931807..8a1d557 100644 --- a/Datafile/Datafile.vcxproj +++ b/Datafile/Datafile.vcxproj @@ -63,6 +63,7 @@ Console true ..\zlib\debug\zlib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + LIBCMTD diff --git a/Datafile/Main.cpp b/Datafile/Main.cpp index dd4370b..0a4bb72 100644 --- a/Datafile/Main.cpp +++ b/Datafile/Main.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -24,6 +25,7 @@ void insertFile(DataArchive& a, const char* sPath, WIN32_FIND_DATA* find) { char sFile[256]; char sFlat[256]; + char sTemp[256]; DWORD find_attrib_forbidden = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_HIDDEN | @@ -32,8 +34,10 @@ void insertFile(DataArchive& a, const char* sPath, WIN32_FIND_DATA* find) if (sPath && *sPath) sprintf(sFile, "%s/%s", sPath, find->cFileName); - else - strcpy(sFile, find->cFileName); + else { + sprintf(sTemp, "%s", find->cFileName); + strcpy(sFile, sTemp); + } if (find->dwFileAttributes & find_attrib_forbidden) { printf(" Skipping: %-48s \n", sFile); @@ -103,7 +107,8 @@ void ins(DataArchive& a, int argc, char* argv[]) sPath[0] = 0; WIN32_FIND_DATA find; - HANDLE h = FindFirstFile(argv[i], &find); + LPCWSTR tmp = (LPCWSTR)argv[i]; + HANDLE h = FindFirstFile(tmp, &find); if (h != INVALID_HANDLE_VALUE) { insertFile(a, sPath, &find); @@ -144,6 +149,14 @@ void buildFile(DataArchive& a, const char* sPath, WIN32_FIND_DATA& find) } } +std::wstring ToWideString(const std::string& str) +{ + int stringLength = MultiByteToWideChar(CP_ACP, 0, str.data(), str.length(), 0, 0); + std::wstring wstr(stringLength, 0); + MultiByteToWideChar(CP_ACP, 0, str.data(), str.length(), &wstr[0], stringLength); + return wstr; +} + void build(DataArchive& a, const char* sBasePath) { char sPath[256]; @@ -159,7 +172,10 @@ void build(DataArchive& a, const char* sBasePath) } WIN32_FIND_DATA find; - HANDLE h = FindFirstFile(sFind, &find); + std::wstring sTemp; + std::string sStd = sFind; + sTemp = ToWideString(sStd); + HANDLE h = FindFirstFile(sTemp.c_str(), &find); if (h != INVALID_HANDLE_VALUE) { do buildFile(a, sPath, find); @@ -196,7 +212,7 @@ int match(const char* sFile, const char* sPattern) } else { nPatternType = PATTERN_STAR_DOT_EXT; - sExt = strchr(sPattern, '.'); + sExt = const_cast(strchr(sPattern, '.')); } } -- cgit v1.1