aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/ijar
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2018-04-24 01:44:17 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-24 01:46:08 -0700
commit8c400c81f224813605dcc9d44d259180a978950a (patch)
treeb49a3e7a314beca8b20f633ea11985f20ca83382 /third_party/ijar
parentce2aa957c89ea7d7850aae767733f4e1f7c73e95 (diff)
windows,client: fix error reporting
Fix error reporting in the path conversion methods of the Bazel client. Previously the error reporting logic used GetLastErrorString in places where it was not appropriate (i.e. it was not a failed Windows API call that caused an error). This cleanup prepares removing the concept of the MSYS root from the Bazel client, since MSYS paths are no longer supported and we want to cut Bazel's dependency on Bash (thus MSYS) completely. See https://github.com/bazelbuild/bazel/issues/4319 Change-Id: Ie50a20e0ee0c572592f637340a2f2948c7f53088 Closes #5072. Change-Id: Ie50a20e0ee0c572592f637340a2f2948c7f53088 PiperOrigin-RevId: 194052665
Diffstat (limited to 'third_party/ijar')
-rw-r--r--third_party/ijar/mapped_file_windows.cc46
-rw-r--r--third_party/ijar/platform_utils.cc5
2 files changed, 29 insertions, 22 deletions
diff --git a/third_party/ijar/mapped_file_windows.cc b/third_party/ijar/mapped_file_windows.cc
index b3327ed89d..91bff719dd 100644
--- a/third_party/ijar/mapped_file_windows.cc
+++ b/third_party/ijar/mapped_file_windows.cc
@@ -48,38 +48,40 @@ MappedInputFile::MappedInputFile(const char* name) {
errmsg_ = errmsg;
wstring wname;
- if (!blaze_util::AsAbsoluteWindowsPath(name, &wname)) {
+ string error;
+ if (!blaze_util::AsAbsoluteWindowsPath(name, &wname, &error)) {
BAZEL_DIE(255) << "MappedInputFile(" << name
- << "): AsAbsoluteWindowsPath failed: "
- << blaze_util::GetLastErrorString();
+ << "): AsAbsoluteWindowsPath failed: " << error;
}
HANDLE file = CreateFileW(wname.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL);
if (file == INVALID_HANDLE_VALUE) {
+ string errormsg = blaze_util::GetLastErrorString();
BAZEL_DIE(255) << "MappedInputFile(" << name << "): CreateFileW("
<< blaze_util::WstringToString(wname)
- << ") failed: " << blaze_util::GetLastErrorString();
+ << ") failed: " << errormsg;
}
LARGE_INTEGER size;
if (!GetFileSizeEx(file, &size)) {
- BAZEL_DIE(255) << "MappedInputFile(" << name << "): GetFileSizeEx failed: "
- << blaze_util::GetLastErrorString();
+ string errormsg = blaze_util::GetLastErrorString();
+ BAZEL_DIE(255) << "MappedInputFile(" << name
+ << "): GetFileSizeEx failed: " << errormsg;
}
HANDLE mapping = CreateFileMapping(file, NULL, PAGE_READONLY,
size.HighPart, size.LowPart, NULL);
if (mapping == NULL || mapping == INVALID_HANDLE_VALUE) {
+ string errormsg = blaze_util::GetLastErrorString();
BAZEL_DIE(255) << "MappedInputFile(" << name
- << "): CreateFileMapping failed: "
- << blaze_util::GetLastErrorString();
+ << "): CreateFileMapping failed: " << errormsg;
}
void *view = MapViewOfFileEx(mapping, FILE_MAP_READ, 0, 0, 0, NULL);
if (view == NULL) {
+ string errormsg = blaze_util::GetLastErrorString();
BAZEL_DIE(255) << "MappedInputFile(" << name
- << "): MapViewOfFileEx failed: "
- << blaze_util::GetLastErrorString();
+ << "): MapViewOfFileEx failed: " << errormsg;
}
impl_ = new MappedInputFileImpl(file, mapping);
@@ -100,18 +102,21 @@ void MappedInputFile::Discard(size_t bytes) {
int MappedInputFile::Close() {
if (!UnmapViewOfFile(buffer_)) {
+ string errormsg = blaze_util::GetLastErrorString();
BAZEL_DIE(255) << "MappedInputFile::Close: UnmapViewOfFile failed: "
- << blaze_util::GetLastErrorString();
+ << errormsg;
}
if (!CloseHandle(impl_->mapping_)) {
+ string errormsg = blaze_util::GetLastErrorString();
BAZEL_DIE(255) << "MappedInputFile::Close: CloseHandle for mapping failed: "
- << blaze_util::GetLastErrorString();
+ << errormsg;
}
if (!CloseHandle(impl_->file_)) {
+ string errormsg = blaze_util::GetLastErrorString();
BAZEL_DIE(255) << "MappedInputFile::Close: CloseHandle for file failed: "
- << blaze_util::GetLastErrorString();
+ << errormsg;
}
return 0;
@@ -133,31 +138,32 @@ MappedOutputFile::MappedOutputFile(const char* name, size_t estimated_size) {
errmsg_ = errmsg;
wstring wname;
- if (!blaze_util::AsAbsoluteWindowsPath(name, &wname)) {
+ string error;
+ if (!blaze_util::AsAbsoluteWindowsPath(name, &wname, &error)) {
BAZEL_DIE(255) << "MappedOutputFile(" << name
- << "): AsAbsoluteWindowsPath failed: "
- << blaze_util::GetLastErrorString();
+ << "): AsAbsoluteWindowsPath failed: " << error;
}
HANDLE file = CreateFileW(wname.c_str(), GENERIC_READ | GENERIC_WRITE, 0,
NULL, CREATE_ALWAYS, 0, NULL);
if (file == INVALID_HANDLE_VALUE) {
+ string errormsg = blaze_util::GetLastErrorString();
BAZEL_DIE(255) << "MappedOutputFile(" << name << "): CreateFileW("
<< blaze_util::WstringToString(wname)
- << ") failed: " << blaze_util::GetLastErrorString();
+ << ") failed: " << errormsg;
}
HANDLE mapping = CreateFileMapping(file, NULL, PAGE_READWRITE,
estimated_size >> 32, estimated_size & 0xffffffffUL, NULL);
if (mapping == NULL || mapping == INVALID_HANDLE_VALUE) {
BAZEL_DIE(255) << "MappedOutputFile(" << name
- << "): CreateFileMapping failed: ";
+ << "): CreateFileMapping failed";
}
void *view = MapViewOfFileEx(mapping, FILE_MAP_ALL_ACCESS, 0, 0, 0, NULL);
if (view == NULL) {
+ string errormsg = blaze_util::GetLastErrorString();
BAZEL_DIE(255) << "MappedOutputFile(" << name
- << "): MapViewOfFileEx failed: "
- << blaze_util::GetLastErrorString();
+ << "): MapViewOfFileEx failed: " << errormsg;
CloseHandle(mapping);
CloseHandle(file);
return;
diff --git a/third_party/ijar/platform_utils.cc b/third_party/ijar/platform_utils.cc
index 9633eb7cee..eeb4c40225 100644
--- a/third_party/ijar/platform_utils.cc
+++ b/third_party/ijar/platform_utils.cc
@@ -39,9 +39,10 @@ using std::string;
bool stat_file(const char* path, Stat* result) {
#if defined(COMPILER_MSVC) || defined(__CYGWIN__)
std::wstring wpath;
- if (!blaze_util::AsAbsoluteWindowsPath(path, &wpath)) {
+ std::string error;
+ if (!blaze_util::AsAbsoluteWindowsPath(path, &wpath, &error)) {
BAZEL_DIE(255) << "stat_file: AsAbsoluteWindowsPath(" << path
- << ") failed: " << blaze_util::GetLastErrorString();
+ << ") failed: " << error;
}
bool success = false;
BY_HANDLE_FILE_INFORMATION info;