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 --- src/mir_core/src/path.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mir_core/src/path.cpp b/src/mir_core/src/path.cpp index f5db1f286d..99d95d9757 100644 --- a/src/mir_core/src/path.cpp +++ b/src/mir_core/src/path.cpp @@ -102,13 +102,12 @@ MIR_CORE_DLL(int) CreateDirectoryTree(const char *szDir) if (szDir == nullptr) return 1; - char szTestDir[MAX_PATH]; - mir_strncpy(szTestDir, szDir, _countof(szTestDir)); - - DWORD dwAttributes = GetFileAttributesA(szTestDir); + DWORD dwAttributes = GetFileAttributesA(szDir); if (dwAttributes != INVALID_FILE_ATTRIBUTES && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)) return 0; + char szTestDir[MAX_PATH]; + mir_strncpy(szTestDir, szDir, _countof(szTestDir)); char *pszLastBackslash = strrchr(szTestDir, '\\'); if (pszLastBackslash == nullptr) return 0; @@ -192,13 +191,12 @@ MIR_CORE_DLL(int) CreateDirectoryTreeW(const wchar_t *szDir) if (szDir == nullptr) return 1; - wchar_t szTestDir[MAX_PATH]; - mir_wstrncpy(szTestDir, szDir, _countof(szTestDir)); - - DWORD dwAttributes = GetFileAttributesW(szTestDir); + DWORD dwAttributes = GetFileAttributesW(szDir); if (dwAttributes != INVALID_FILE_ATTRIBUTES && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)) return 0; + wchar_t szTestDir[MAX_PATH]; + mir_wstrncpy(szTestDir, szDir, _countof(szTestDir)); wchar_t *pszLastBackslash = wcsrchr(szTestDir, '\\'); if (pszLastBackslash == nullptr) return 0; -- cgit v1.2.3