Switch over to the google3 unix_file File*.
I also moved macros.h to base/macros.h to ease google3 porting, at
the expense of a larger than necessary change. (I learned my lesson,
though, and didn't make the equivalent base/logging.h change.)
I'm not sure whether we want to keep the unix_file MappedFile given
our existing MemMap, but it's easier to bring it over and then remove
it (and possibly revert the removal) than to bring it over later.
Change-Id: Id50a66faa5ab17b9bc936cc9043dbc26f791f0ca
diff --git a/src/utils.cc b/src/utils.cc
index 3cf6914..78d3599 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -24,8 +24,8 @@
#include <unistd.h>
#include "UniquePtr.h"
+#include "base/unix_file/fd_file.h"
#include "class_loader.h"
-#include "file.h"
#include "object.h"
#include "object_utils.h"
#include "os.h"
@@ -95,14 +95,14 @@
}
bool ReadFileToString(const std::string& file_name, std::string* result) {
- UniquePtr<File> file(OS::OpenFile(file_name.c_str(), false));
- if (file.get() == NULL) {
+ UniquePtr<File> file(new File);
+ if (!file->Open(file_name, O_RDONLY)) {
return false;
}
std::vector<char> buf(8 * KB);
while (true) {
- int64_t n = file->Read(&buf[0], buf.size());
+ int64_t n = TEMP_FAILURE_RETRY(read(file->Fd(), &buf[0], buf.size()));
if (n == -1) {
return false;
}