From 2206ba098529559c793befa474f636da64717619 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Nov 2015 12:31:17 -0500 Subject: [PATCH 1/4] inverted the inverted file flags condition --- Source/Common/File Class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index f9eb583eb..e6ab04651 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -82,7 +82,7 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags) ULONG dwCreateFlag = 0; if (nOpenFlags & modeCreate) { - dwCreateFlag = nOpenFlags & modeNoTruncate == 0 ? OPEN_ALWAYS : CREATE_ALWAYS; + dwCreateFlag = nOpenFlags & modeNoTruncate != 0 ? OPEN_ALWAYS : CREATE_ALWAYS; } else { From d9ef1cae17ace6a663147a59c6331bca5cc78e51 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Nov 2015 12:32:49 -0500 Subject: [PATCH 2/4] fixed implicit (but wrong) operator precedence --- Source/Common/File Class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index e6ab04651..50416675f 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -82,7 +82,7 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags) ULONG dwCreateFlag = 0; if (nOpenFlags & modeCreate) { - dwCreateFlag = nOpenFlags & modeNoTruncate != 0 ? OPEN_ALWAYS : CREATE_ALWAYS; + dwCreateFlag = (nOpenFlags & modeNoTruncate) != 0 ? OPEN_ALWAYS : CREATE_ALWAYS; } else { From ade04862f8631e34ed51face5b3e180ff2754266 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Nov 2015 12:43:57 -0500 Subject: [PATCH 3/4] minor clean-ups --- Source/Common/File Class.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index 50416675f..f2f431bff 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -79,14 +79,12 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags) sa.bInheritHandle = (nOpenFlags & modeNoInherit) == 0; // map creation flags - ULONG dwCreateFlag = 0; + ULONG dwCreateFlag = OPEN_EXISTING; if (nOpenFlags & modeCreate) { - dwCreateFlag = (nOpenFlags & modeNoTruncate) != 0 ? OPEN_ALWAYS : CREATE_ALWAYS; - } - else - { - dwCreateFlag = OPEN_EXISTING; + dwCreateFlag = + ((nOpenFlags & modeNoTruncate) != 0) + ? OPEN_ALWAYS : CREATE_ALWAYS; } // attempt file creation From 0174bae7a8cb5eea2eb4976e6042a7fc0db8c5b3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Nov 2015 18:08:24 -0500 Subject: [PATCH 4/4] combined fix into a single line --- Source/Common/File Class.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index f2f431bff..cc73de345 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -82,9 +82,7 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags) ULONG dwCreateFlag = OPEN_EXISTING; if (nOpenFlags & modeCreate) { - dwCreateFlag = - ((nOpenFlags & modeNoTruncate) != 0) - ? OPEN_ALWAYS : CREATE_ALWAYS; + dwCreateFlag = ((nOpenFlags & modeNoTruncate) != 0) ? OPEN_ALWAYS : CREATE_ALWAYS; } // attempt file creation