From 40686cc1869953a42f311b6d8a3558e99acef37d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 16 Feb 2020 14:35:10 +0300 Subject: useless checks removed --- plugins/Toaster/src/main.cpp | 5 +---- plugins/TrafficCounter/src/statistics.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/Toaster/src/main.cpp b/plugins/Toaster/src/main.cpp index 7aeb3bee78..470399a83d 100644 --- a/plugins/Toaster/src/main.cpp +++ b/plugins/Toaster/src/main.cpp @@ -61,10 +61,7 @@ int CMPlugin::Load() if (GetEnvironmentVariableW(L"TEMP", wszTempDir, MAX_PATH) != 0) { wcscat_s(wszTempDir, L"\\Miranda.Toaster"); - - DWORD dwAttributes = GetFileAttributes(wszTempDir); - if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) - CreateDirectoryTreeW(wszTempDir); + CreateDirectoryTreeW(wszTempDir); } else MessageBox(nullptr, TranslateT("Failed to create temporary directory"), _T(MODULENAME), MB_OK | MB_ICONERROR); diff --git a/plugins/TrafficCounter/src/statistics.cpp b/plugins/TrafficCounter/src/statistics.cpp index a0872b769e..b97e34b7b1 100644 --- a/plugins/TrafficCounter/src/statistics.cpp +++ b/plugins/TrafficCounter/src/statistics.cpp @@ -296,13 +296,14 @@ void Stat_ReadFile(PROTOLIST &p) { LARGE_INTEGER Size; DWORD BytesRead; - wchar_t FileName[MAX_PATH], *pszPath; - SYSTEMTIME stNow; + wchar_t FileName[MAX_PATH]; + { + VARSW pszPath(Utils_ReplaceVarsW(L"%miranda_userdata%\\statistics")); + CreateDirectoryTreeW(pszPath); + mir_snwprintf(FileName, L"%s\\%S.stat", pszPath.get(), p.name); + } - pszPath = Utils_ReplaceVarsW(L"%miranda_userdata%\\statistics"); - CreateDirectoryTreeW(pszPath); - mir_snwprintf(FileName, L"%s\\%S.stat", pszPath, p.name); - mir_free(pszPath); + SYSTEMTIME stNow; GetLocalTime(&stNow); p.hFile = CreateFile(FileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); -- cgit v1.2.3