summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-03-21 20:31:49 +0100
committerCarl Hetherington <cth@carlh.net>2024-03-21 20:31:49 +0100
commit96cafdac487e5393e970cd9ec9d51ce89598c799 (patch)
tree00f7b0ce8e5400b7e368f4d62c4564f450ded424
parentd82b32df5518a12a3c96e7066f925604c5a4f2b9 (diff)
Log actual error codes from CreateFileW failures.
-rw-r--r--src/KM_fileio.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/KM_fileio.cpp b/src/KM_fileio.cpp
index 14bb16a..e38d030 100644
--- a/src/KM_fileio.cpp
+++ b/src/KM_fileio.cpp
@@ -916,10 +916,17 @@ Kumu::FileReader::OpenRead(const std::string& filename) const
NULL // no template file
);
+ HRESULT const last_error = GetLastError();
+
::SetErrorMode(prev);
- return ( m_Handle == INVALID_HANDLE_VALUE ) ?
- Kumu::RESULT_FILEOPEN : Kumu::RESULT_OK;
+ if (m_Handle == INVALID_HANDLE_VALUE)
+ {
+ DefaultLogSink().Error("CreateFileW failed: %lu", last_error);
+ return Kumu::RESULT_FILEOPEN;
+ }
+
+ return Kumu::RESULT_OK;
}
//
@@ -1054,11 +1061,16 @@ Kumu::FileWriter::OpenWrite(const std::string& filename)
NULL // no template file
);
+ HRESULT const last_error = GetLastError();
+
::SetErrorMode(prev);
- if ( m_Handle == INVALID_HANDLE_VALUE )
- return Kumu::RESULT_FILEOPEN;
-
+ if (m_Handle == INVALID_HANDLE_VALUE)
+ {
+ DefaultLogSink().Error("CreateFileW failed: %lu\n", last_error);
+ return Kumu::RESULT_FILEOPEN;
+ }
+
m_IOVec = new h__iovec;
return Kumu::RESULT_OK;
}