@@ -100,11 +100,11 @@ bool loadFromResourceFile(const int resourceID, string& retString)
100100{
101101#ifdef _WIN32
102102 // Can load directly from windows resource file
103- HINSTANCE hInst = GetModuleHandle (nullptr );
104- HRSRC hRes = FindResource (hInst, MAKEINTRESOURCE (resourceID), RT_RCDATA);
105- HGLOBAL hMem = LoadResource (hInst, hRes);
106- DWORD size = SizeofResource (hInst, hRes);
107- char * resText = static_cast <char *>(LockResource (hMem));
103+ const HINSTANCE hInst = GetModuleHandleA (nullptr );
104+ const HRSRC hRes = FindResourceA (hInst, MAKEINTRESOURCE (resourceID), RT_RCDATA);
105+ const HGLOBAL hMem = LoadResource (hInst, hRes);
106+ const DWORD size = SizeofResource (hInst, hRes);
107+ const char * resText = static_cast <char *>(LockResource (hMem));
108108
109109 // Copy across the file
110110 retString.reserve (size);
@@ -154,11 +154,11 @@ bool copyResourceFile(const int resourceID, const string& destinationFile, const
154154{
155155#ifdef _WIN32
156156 // Can load directly from windows resource file
157- HINSTANCE hInst = GetModuleHandle (nullptr );
158- HRSRC hRes = FindResource (hInst, MAKEINTRESOURCE (resourceID), RT_RCDATA);
159- HGLOBAL hMem = LoadResource (hInst, hRes);
157+ const HINSTANCE hInst = GetModuleHandleA (nullptr );
158+ const HRSRC hRes = FindResourceA (hInst, MAKEINTRESOURCE (resourceID), RT_RCDATA);
159+ const HGLOBAL hMem = LoadResource (hInst, hRes);
160160 DWORD size = SizeofResource (hInst, hRes);
161- char * resText = static_cast <char *>(LockResource (hMem));
161+ const char * resText = static_cast <char *>(LockResource (hMem));
162162
163163 // Copy across the file
164164 ofstream dest (destinationFile, (binary) ? ios_base::out | ios_base::binary : ios_base::out);
@@ -195,7 +195,7 @@ bool copyResourceFile(const int resourceID, const string& destinationFile, const
195195void deleteFile (const string& destinationFile)
196196{
197197#ifdef _WIN32
198- DeleteFile (destinationFile.c_str ());
198+ DeleteFileA (destinationFile.c_str ());
199199#else
200200 remove (destinationFile.c_str ());
201201#endif
@@ -204,9 +204,9 @@ void deleteFile(const string& destinationFile)
204204void deleteFolder (const string& destinationFolder)
205205{
206206#ifdef _WIN32
207- string delFolder = destinationFolder + ' \0 ' ;
207+ const string delFolder = destinationFolder + ' \0 ' ;
208208 SHFILEOPSTRUCT file_op = {NULL , FO_DELETE, delFolder.c_str (), " " , FOF_NO_UI, false , 0 , " " };
209- SHFileOperation (&file_op);
209+ SHFileOperationA (&file_op);
210210#else
211211 DIR* p_Dir = opendir (destinationFolder.c_str ());
212212 size_t path_len = strlen (destinationFolder.c_str ());
@@ -246,7 +246,7 @@ void deleteFolder(const string& destinationFolder)
246246bool isFolderEmpty (const string& folder)
247247{
248248#ifdef _WIN32
249- return PathIsDirectoryEmpty (folder.c_str ());
249+ return PathIsDirectoryEmptyA (folder.c_str ()) == TRUE ;
250250#else
251251 DIR* dir = opendir (folder.c_str ());
252252 if (dir == NULL ) {
@@ -268,7 +268,7 @@ bool isFolderEmpty(const string& folder)
268268bool copyFile (const string& sourceFolder, const string& destinationFolder)
269269{
270270#ifdef _WIN32
271- return (CopyFile (sourceFolder.c_str (), destinationFolder.c_str (), false ) != 0 );
271+ return (CopyFileA (sourceFolder.c_str (), destinationFolder.c_str (), false ) != 0 );
272272#else
273273 FILE* p_Source = fopen (sourceFolder.c_str (), " rb" );
274274 if (p_Source == NULL )
@@ -350,7 +350,7 @@ bool findFile(const string& fileName, string& retFileName)
350350{
351351#ifdef _WIN32
352352 WIN32_FIND_DATA searchFile;
353- HANDLE searchHandle = FindFirstFile (fileName.c_str (), &searchFile);
353+ const HANDLE searchHandle = FindFirstFileA (fileName.c_str (), &searchFile);
354354 if (searchHandle != INVALID_HANDLE_VALUE) {
355355 // Update the return filename
356356 retFileName = searchFile.cFileName ;
@@ -395,7 +395,7 @@ bool findFiles(const string& fileSearch, vector<string>& retFiles, const bool re
395395 }
396396 // Search all sub directories as well
397397 if (recursive) {
398- string search = path + " *" ;
398+ const string search = path + " *" ;
399399 searchHandle = FindFirstFile (search.c_str (), &searchFile);
400400 if (searchHandle != INVALID_HANDLE_VALUE) {
401401 BOOL cont = TRUE ;
@@ -443,11 +443,11 @@ bool findFolders(const string& folderSearch, vector<string>& retFolders, const b
443443 path = folderSearch.substr (0 , pos);
444444 searchTerm = folderSearch.substr (pos);
445445 }
446- HANDLE searchHandle = FindFirstFile (folderSearch.c_str (), &searchFile);
446+ HANDLE searchHandle = FindFirstFileA (folderSearch.c_str (), &searchFile);
447447 if (searchHandle != INVALID_HANDLE_VALUE) {
448448 // Update the return filename list
449449 retFolders.push_back (path + searchFile.cFileName );
450- while (FindNextFile (searchHandle, &searchFile) != 0 ) {
450+ while (FindNextFileA (searchHandle, &searchFile) != 0 ) {
451451 if (searchFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
452452 retFolders.push_back (path + searchFile.cFileName );
453453 replace (retFolders.back ().begin (), retFolders.back ().end (), ' \\ ' , ' /' );
@@ -457,8 +457,8 @@ bool findFolders(const string& folderSearch, vector<string>& retFolders, const b
457457 }
458458 // Search all sub directories as well
459459 if (recursive) {
460- string search = path + " *" ;
461- searchHandle = FindFirstFile (search.c_str (), &searchFile);
460+ const string search = path + " *" ;
461+ searchHandle = FindFirstFileA (search.c_str (), &searchFile);
462462 if (searchHandle != INVALID_HANDLE_VALUE) {
463463 BOOL cont = TRUE ;
464464 while (cont == TRUE ) {
@@ -469,7 +469,7 @@ bool findFolders(const string& folderSearch, vector<string>& retFolders, const b
469469 findFolders (newPath, retFolders);
470470 }
471471 }
472- cont = FindNextFile (searchHandle, &searchFile);
472+ cont = FindNextFileA (searchHandle, &searchFile);
473473 }
474474 FindClose (searchHandle);
475475 }
@@ -497,16 +497,16 @@ void makePathsRelative(const string& path, const string& makeRelativeTo, string&
497497 fromT.reserve (MAX_PATH);
498498 toT.reserve (MAX_PATH);
499499 if (path.length () > 0 ) {
500- GetFullPathName (path.c_str (), MAX_PATH, const_cast <char *>(fromT.data ()), NULL );
500+ GetFullPathNameA (path.c_str (), MAX_PATH, const_cast <char *>(fromT.data ()), NULL );
501501 } else {
502- GetFullPathName (" ./" , MAX_PATH, const_cast <char *>(fromT.data ()), NULL );
502+ GetFullPathNameA (" ./" , MAX_PATH, const_cast <char *>(fromT.data ()), NULL );
503503 }
504504 if (makeRelativeTo.length () > 0 ) {
505- GetFullPathName (makeRelativeTo.c_str (), MAX_PATH, const_cast <char *>(toT.data ()), NULL );
505+ GetFullPathNameA (makeRelativeTo.c_str (), MAX_PATH, const_cast <char *>(toT.data ()), NULL );
506506 } else {
507- GetFullPathName (" ./" , MAX_PATH, const_cast <char *>(toT.data ()), NULL );
507+ GetFullPathNameA (" ./" , MAX_PATH, const_cast <char *>(toT.data ()), NULL );
508508 }
509- PathRelativePathTo (
509+ PathRelativePathToA (
510510 const_cast <char *>(retPath.data ()), toT.c_str (), FILE_ATTRIBUTE_DIRECTORY, fromT.c_str (), FILE_ATTRIBUTE_NORMAL);
511511 retPath.resize (strlen (retPath.c_str ()));
512512 replace (retPath.begin (), retPath.end (), ' \\ ' , ' /' );
@@ -568,7 +568,7 @@ void findAndReplace(string& inString, const string& search, const string& replac
568568bool findEnvironmentVariable (const string& envVar)
569569{
570570#ifdef _WIN32
571- return (GetEnvironmentVariable (envVar.c_str (), NULL , 0 ) > 0 );
571+ return (GetEnvironmentVariableA (envVar.c_str (), NULL , 0 ) > 0 );
572572#else
573573 return false ;
574574#endif
@@ -591,7 +591,7 @@ void outputLine(const string& message)
591591void outputInfo (const string& message, const bool header)
592592{
593593#if _WIN32
594- HANDLE hstdout = GetStdHandle (STD_OUTPUT_HANDLE);
594+ const HANDLE hstdout = GetStdHandle (STD_OUTPUT_HANDLE);
595595 CONSOLE_SCREEN_BUFFER_INFO csbi;
596596 GetConsoleScreenBufferInfo (hstdout, &csbi);
597597 SetConsoleTextAttribute (hstdout, FOREGROUND_GREEN);
@@ -612,7 +612,7 @@ void outputInfo(const string& message, const bool header)
612612void outputWarning (const string& message, const bool header)
613613{
614614#if _WIN32
615- HANDLE hstdout = GetStdHandle (STD_OUTPUT_HANDLE);
615+ const HANDLE hstdout = GetStdHandle (STD_OUTPUT_HANDLE);
616616 CONSOLE_SCREEN_BUFFER_INFO csbi;
617617 GetConsoleScreenBufferInfo (hstdout, &csbi);
618618 SetConsoleTextAttribute (hstdout, FOREGROUND_RED | FOREGROUND_GREEN);
@@ -633,7 +633,7 @@ void outputWarning(const string& message, const bool header)
633633void outputError (const string& message, const bool header)
634634{
635635#if _WIN32
636- HANDLE hstdout = GetStdHandle (STD_OUTPUT_HANDLE);
636+ const HANDLE hstdout = GetStdHandle (STD_OUTPUT_HANDLE);
637637 CONSOLE_SCREEN_BUFFER_INFO csbi;
638638 GetConsoleScreenBufferInfo (hstdout, &csbi);
639639 SetConsoleTextAttribute (hstdout, FOREGROUND_RED);
0 commit comments