diff --git a/include/CoolPropTools.h b/include/CoolPropTools.h index 38b8ed0f..827b21c8 100644 --- a/include/CoolPropTools.h +++ b/include/CoolPropTools.h @@ -117,11 +117,12 @@ { return (path == L"." || path == L".."); } - inline unsigned long long CalculateDirSize(const std::wstring &path, std::vector *errVect = NULL, unsigned long long size = 0) + inline unsigned long long CalculateDirSize(const std::wstring &path, std::vector *errVect = NULL) { - WIN32_FIND_DATA data; + unsigned long long size = 0; + WIN32_FIND_DATAW data; HANDLE sh = NULL; - sh = FindFirstFile((path + L"\\*").c_str(), &data); + sh = FindFirstFileW((path + L"\\*").c_str(), &data); if (sh == INVALID_HANDLE_VALUE ) { @@ -137,15 +138,15 @@ if (!IsBrowsePath(data.cFileName)) { // if found object is ... - if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) + if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // directory, then search it recursievly - size = CalculateDirSize(path + L"\\" + data.cFileName, NULL, size); + size += CalculateDirSize(path + L"\\" + data.cFileName, NULL); else // otherwise get object size and add it to directory size - size += (unsigned long long) (data.nFileSizeHigh * (MAXDWORD ) + data.nFileSizeLow); + size += data.nFileSizeHigh * (unsigned long long)(MAXDWORD) + data.nFileSizeLow; } - } while (FindNextFile(sh, &data)); // do + } while (FindNextFileW(sh, &data)); // do FindClose(sh); diff --git a/src/CoolPropTools.cpp b/src/CoolPropTools.cpp index 559cb560..18c83b6a 100644 --- a/src/CoolPropTools.cpp +++ b/src/CoolPropTools.cpp @@ -17,7 +17,7 @@ #include #include -static double ftw_summer; // An evil global variable for the ftw function +static thread_local unsigned long long ftw_summer; // An evil global variable for the ftw function int ftw_function(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftwbuf){ ftw_summer += sb->st_size; return 0; /* To tell nftw() to continue */