This is an automated email from the ASF dual-hosted git repository. wesm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push: new 263c287 ARROW-5700: [C++] Try to produce better errors on Windows 263c287 is described below commit 263c28721048b042a586264439c65115123d39b8 Author: Antoine Pitrou <anto...@python.org> AuthorDate: Thu Jun 27 13:29:10 2019 -0500 ARROW-5700: [C++] Try to produce better errors on Windows Using GetLastError() if possible may produce more precise diagnostics than errno, since typically one errno can map to several different Windows error codes. Author: Antoine Pitrou <anto...@python.org> Closes #4724 from pitrou/ARROW-5700-better-win-error-message and squashes the following commits: 5f866c27b <Antoine Pitrou> ARROW-5700: Try to produce better errors on Windows --- cpp/src/arrow/util/io-util.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cpp/src/arrow/util/io-util.cc b/cpp/src/arrow/util/io-util.cc index 87f64b7..c092769 100644 --- a/cpp/src/arrow/util/io-util.cc +++ b/cpp/src/arrow/util/io-util.cc @@ -407,6 +407,13 @@ static inline Status CheckFileOpResult(int ret, int errno_actual, const PlatformFilename& file_name, const char* opname) { if (ret == -1) { +#ifdef _WIN32 + int winerr = GetLastError(); + if (winerr != ERROR_SUCCESS) { + return Status::IOError("Failed to ", opname, " file '", file_name.ToString(), + "', error: ", WinErrorMessage(winerr)); + } +#endif return Status::IOError("Failed to ", opname, " file '", file_name.ToString(), "', error: ", ErrnoMessage(errno_actual)); } @@ -416,6 +423,7 @@ static inline Status CheckFileOpResult(int ret, int errno_actual, Status FileOpenReadable(const PlatformFilename& file_name, int* fd) { int ret, errno_actual; #if defined(_WIN32) + SetLastError(0); errno_actual = _wsopen_s(fd, file_name.ToNative().c_str(), _O_RDONLY | _O_BINARY | _O_NOINHERIT, _SH_DENYNO, _S_IREAD); ret = *fd; @@ -446,6 +454,7 @@ Status FileOpenWritable(const PlatformFilename& file_name, bool write_only, bool int ret, errno_actual; #if defined(_WIN32) + SetLastError(0); int oflag = _O_CREAT | _O_BINARY | _O_NOINHERIT; int pmode = _S_IREAD | _S_IWRITE;