summaryrefslogtreecommitdiff
path: root/runtime/base/file_magic.cc
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2016-07-16 04:46:46 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-07-16 04:46:46 +0000
commit173f435e56acfd0501fc460747572a4796dcffe0 (patch)
tree5e5716d1b07f229efb78783d26518511539ef5a3 /runtime/base/file_magic.cc
parent161c866ca742049f5c916696e1503c697be30e87 (diff)
parent43e10b031e3bb42df54adf8f0525a29d2b308a4e (diff)
Merge "ART: Replace ScopedFd with FdFile"
Diffstat (limited to 'runtime/base/file_magic.cc')
-rw-r--r--runtime/base/file_magic.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/runtime/base/file_magic.cc b/runtime/base/file_magic.cc
index 97563382a1..de6f4237ff 100644
--- a/runtime/base/file_magic.cc
+++ b/runtime/base/file_magic.cc
@@ -21,27 +21,28 @@
#include <sys/types.h>
#include "base/logging.h"
+#include "base/unix_file/fd_file.h"
#include "dex_file.h"
#include "stringprintf.h"
namespace art {
-ScopedFd OpenAndReadMagic(const char* filename, uint32_t* magic, std::string* error_msg) {
+File OpenAndReadMagic(const char* filename, uint32_t* magic, std::string* error_msg) {
CHECK(magic != nullptr);
- ScopedFd fd(open(filename, O_RDONLY, 0));
- if (fd.get() == -1) {
+ File fd(filename, O_RDONLY, /* check_usage */ false);
+ if (fd.Fd() == -1) {
*error_msg = StringPrintf("Unable to open '%s' : %s", filename, strerror(errno));
- return ScopedFd();
+ return File();
}
- int n = TEMP_FAILURE_RETRY(read(fd.get(), magic, sizeof(*magic)));
+ int n = TEMP_FAILURE_RETRY(read(fd.Fd(), magic, sizeof(*magic)));
if (n != sizeof(*magic)) {
*error_msg = StringPrintf("Failed to find magic in '%s'", filename);
- return ScopedFd();
+ return File();
}
- if (lseek(fd.get(), 0, SEEK_SET) != 0) {
+ if (lseek(fd.Fd(), 0, SEEK_SET) != 0) {
*error_msg = StringPrintf("Failed to seek to beginning of file '%s' : %s", filename,
strerror(errno));
- return ScopedFd();
+ return File();
}
return fd;
}