Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cpp/src/arrow/util/io-util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down