aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/ijar
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2018-03-29 11:13:24 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-29 11:14:35 -0700
commitc5a5880c4797a60ef123d6ba8b0db4f984ebf36d (patch)
treedaa36705d5141b6fe2e3a4b577ecd242aed6825f /third_party/ijar
parent083be7a8f972a060e4e263819e0e9080b5aa6929 (diff)
Remove pdie.
pdie and die are pretty similar, pdie just adds the errno string or equivalent from GetLastErrorString(). Make this explicit. This makes message formatting more clear in preparation for moving these all to BAZEL_LOG. RELNOTES: None. PiperOrigin-RevId: 190957255
Diffstat (limited to 'third_party/ijar')
-rw-r--r--third_party/ijar/mapped_file_windows.cc62
-rw-r--r--third_party/ijar/platform_utils.cc3
2 files changed, 45 insertions, 20 deletions
diff --git a/third_party/ijar/mapped_file_windows.cc b/third_party/ijar/mapped_file_windows.cc
index abc93c2791..6fb8b369d6 100644
--- a/third_party/ijar/mapped_file_windows.cc
+++ b/third_party/ijar/mapped_file_windows.cc
@@ -46,29 +46,36 @@ MappedInputFile::MappedInputFile(const char* name) {
wstring wname;
if (!blaze_util::AsAbsoluteWindowsPath(name, &wname)) {
- blaze_util::pdie(255, "MappedInputFile(%s): AsAbsoluteWindowsPath", name);
+ blaze_util::die(255,
+ "MappedInputFile(%s): AsAbsoluteWindowsPath failed: %s",
+ name, blaze_util::GetLastErrorString().c_str());
}
HANDLE file = CreateFileW(wname.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL);
if (file == INVALID_HANDLE_VALUE) {
- blaze_util::pdie(255, "MappedInputFile(%s): CreateFileW(%S)", name,
- wname.c_str());
+ blaze_util::die(255, "MappedInputFile(%s): CreateFileW(%S) failed: %s",
+ name, wname.c_str(),
+ blaze_util::GetLastErrorString().c_str());
}
LARGE_INTEGER size;
if (!GetFileSizeEx(file, &size)) {
- blaze_util::pdie(255, "MappedInputFile(%s): GetFileSizeEx", name);
+ blaze_util::die(255, "MappedInputFile(%s): GetFileSizeEx failed: %s", name,
+ blaze_util::GetLastErrorString().c_str());
}
HANDLE mapping = CreateFileMapping(file, NULL, PAGE_READONLY,
size.HighPart, size.LowPart, NULL);
if (mapping == NULL || mapping == INVALID_HANDLE_VALUE) {
- blaze_util::pdie(255, "MappedInputFile(%s): CreateFileMapping", name);
+ blaze_util::die(255, "MappedInputFile(%s): CreateFileMapping failed: %s",
+ name),
+ blaze_util::GetLastErrorString().c_str();
}
void *view = MapViewOfFileEx(mapping, FILE_MAP_READ, 0, 0, 0, NULL);
if (view == NULL) {
- blaze_util::pdie(255, "MappedInputFile(%s): MapViewOfFileEx", name);
+ blaze_util::die(255, "MappedInputFile(%s): MapViewOfFileEx failed: %s",
+ name, blaze_util::GetLastErrorString().c_str());
}
impl_ = new MappedInputFileImpl(file, mapping);
@@ -89,15 +96,20 @@ void MappedInputFile::Discard(size_t bytes) {
int MappedInputFile::Close() {
if (!UnmapViewOfFile(buffer_)) {
- blaze_util::pdie(255, "MappedInputFile::Close: UnmapViewOfFile");
+ blaze_util::die(255, "MappedInputFile::Close: UnmapViewOfFile failed: %s",
+ blaze_util::GetLastErrorString().c_str());
}
if (!CloseHandle(impl_->mapping_)) {
- blaze_util::pdie(255, "MappedInputFile::Close: CloseHandle for mapping");
+ blaze_util::die(
+ 255, "MappedInputFile::Close: CloseHandle for mapping failed: %s",
+ blaze_util::GetLastErrorString().c_str());
}
if (!CloseHandle(impl_->file_)) {
- blaze_util::pdie(255, "MappedInputFile::Close: CloseHandle for file");
+ blaze_util::die(255,
+ "MappedInputFile::Close: CloseHandle for file failed: %s",
+ blaze_util::GetLastErrorString().c_str());
}
return 0;
@@ -120,24 +132,29 @@ MappedOutputFile::MappedOutputFile(const char* name, u8 estimated_size) {
wstring wname;
if (!blaze_util::AsAbsoluteWindowsPath(name, &wname)) {
- blaze_util::pdie(255, "MappedOutputFile(%s): AsAbsoluteWindowsPath", name);
+ blaze_util::die(255,
+ "MappedOutputFile(%s): AsAbsoluteWindowsPath failed: %s",
+ name, blaze_util::GetLastErrorString().c_str());
}
HANDLE file = CreateFileW(wname.c_str(), GENERIC_READ | GENERIC_WRITE, 0,
NULL, CREATE_ALWAYS, 0, NULL);
if (file == INVALID_HANDLE_VALUE) {
- blaze_util::pdie(255, "MappedOutputFile(%s): CreateFileW(%S)", name,
- wname.c_str());
+ blaze_util::die(255, "MappedOutputFile(%s): CreateFileW(%S) failed: %s",
+ name, wname.c_str(),
+ blaze_util::GetLastErrorString().c_str());
}
HANDLE mapping = CreateFileMapping(file, NULL, PAGE_READWRITE,
estimated_size >> 32, estimated_size & 0xffffffffUL, NULL);
if (mapping == NULL || mapping == INVALID_HANDLE_VALUE) {
- blaze_util::pdie(255, "MappedOutputFile(%s): CreateFileMapping", name);
+ blaze_util::die(255, "MappedOutputFile(%s): CreateFileMapping failed: %s",
+ name);
}
void *view = MapViewOfFileEx(mapping, FILE_MAP_ALL_ACCESS, 0, 0, 0, NULL);
if (view == NULL) {
- blaze_util::pdie(255, "MappedOutputFile(%s): MapViewOfFileEx", name);
+ blaze_util::die(255, "MappedOutputFile(%s): MapViewOfFileEx failed: %s",
+ name, blaze_util::GetLastErrorString().c_str());
CloseHandle(mapping);
CloseHandle(file);
return;
@@ -154,23 +171,30 @@ MappedOutputFile::~MappedOutputFile() {
int MappedOutputFile::Close(int size) {
if (!UnmapViewOfFile(buffer_)) {
- blaze_util::pdie(255, "MappedOutputFile::Close: UnmapViewOfFile");
+ blaze_util::die(255, "MappedOutputFile::Close: UnmapViewOfFile failed: %s",
+ blaze_util::GetLastErrorString().c_str());
}
if (!CloseHandle(impl_->mapping_)) {
- blaze_util::pdie(255, "MappedOutputFile::Close: CloseHandle for mapping");
+ blaze_util::die(
+ 255, "MappedOutputFile::Close: CloseHandle for mapping failed: %s",
+ blaze_util::GetLastErrorString().c_str());
}
if (!SetFilePointer(impl_->file_, size, NULL, FILE_BEGIN)) {
- blaze_util::pdie(255, "MappedOutputFile::Close: SetFilePointer");
+ blaze_util::die(255, "MappedOutputFile::Close: SetFilePointer failed: %s",
+ blaze_util::GetLastErrorString().c_str());
}
if (!SetEndOfFile(impl_->file_)) {
- blaze_util::pdie(255, "MappedOutputFile::Close: SetEndOfFile");
+ blaze_util::die(255, "MappedOutputFile::Close: SetEndOfFile failed: %s",
+ blaze_util::GetLastErrorString().c_str());
}
if (!CloseHandle(impl_->file_)) {
- blaze_util::pdie(255, "MappedOutputFile::Close: CloseHandle for file");
+ blaze_util::die(255,
+ "MappedOutputFile::Close: CloseHandle for file failed: %s",
+ blaze_util::GetLastErrorString().c_str());
}
return 0;
diff --git a/third_party/ijar/platform_utils.cc b/third_party/ijar/platform_utils.cc
index dde8868005..09818f7162 100644
--- a/third_party/ijar/platform_utils.cc
+++ b/third_party/ijar/platform_utils.cc
@@ -39,7 +39,8 @@ bool stat_file(const char* path, Stat* result) {
#if defined(COMPILER_MSVC) || defined(__CYGWIN__)
std::wstring wpath;
if (!blaze_util::AsAbsoluteWindowsPath(path, &wpath)) {
- blaze_util::pdie(255, "stat_file: AsAbsoluteWindowsPath(%s)", path);
+ blaze_util::die(255, "stat_file: AsAbsoluteWindowsPath(%s) failed: %s",
+ path, blaze_util::GetLastErrorString().c_str());
}
bool success = false;
BY_HANDLE_FILE_INFORMATION info;