ART: Replace ScopedFd with FdFile
FdFile can now be used like ScopedFd. Remove ScopedFd.
Bug: 21192156
Test: m test-art-host
Test: m test-art-target (shamu)
Change-Id: I32115fa8b2b8bb5aa5d1886eae63522f80ce836b
diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc
index 41b1960..18ebfeb 100644
--- a/compiler/oat_test.cc
+++ b/compiler/oat_test.cc
@@ -158,7 +158,7 @@
}
bool WriteElf(File* file,
- ScopedFd&& zip_fd,
+ File&& zip_fd,
const char* location,
SafeMap<std::string, std::string>& key_value_store,
bool verify) {
@@ -708,8 +708,8 @@
{
// Test using the AddZipDexFileSource() interface with the zip file handle.
- ScopedFd zip_fd(dup(zip_file.GetFd()));
- ASSERT_NE(-1, zip_fd.get());
+ File zip_fd(dup(zip_file.GetFd()), /* check_usage */ false);
+ ASSERT_NE(-1, zip_fd.Fd());
ScratchFile oat_file;
success = WriteElf(oat_file.GetFile(),
diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc
index cdc7df1..b32199f 100644
--- a/compiler/oat_writer.cc
+++ b/compiler/oat_writer.cc
@@ -323,14 +323,14 @@
DCHECK(write_state_ == WriteState::kAddingDexFileSources);
uint32_t magic;
std::string error_msg;
- ScopedFd fd(OpenAndReadMagic(filename, &magic, &error_msg));
- if (fd.get() == -1) {
+ File fd = OpenAndReadMagic(filename, &magic, &error_msg);
+ if (fd.Fd() == -1) {
PLOG(ERROR) << "Failed to read magic number from dex file: '" << filename << "'";
return false;
} else if (IsDexMagic(magic)) {
// The file is open for reading, not writing, so it's OK to let the File destructor
// close it without checking for explicit Close(), so pass checkUsage = false.
- raw_dex_files_.emplace_back(new File(fd.release(), location, /* checkUsage */ false));
+ raw_dex_files_.emplace_back(new File(fd.Release(), location, /* checkUsage */ false));
oat_dex_files_.emplace_back(location,
DexFileSource(raw_dex_files_.back().get()),
create_type_lookup_table);
@@ -346,12 +346,12 @@
}
// Add dex file source(s) from a zip file specified by a file handle.
-bool OatWriter::AddZippedDexFilesSource(ScopedFd&& zip_fd,
+bool OatWriter::AddZippedDexFilesSource(File&& zip_fd,
const char* location,
CreateTypeLookupTable create_type_lookup_table) {
DCHECK(write_state_ == WriteState::kAddingDexFileSources);
std::string error_msg;
- zip_archives_.emplace_back(ZipArchive::OpenFromFd(zip_fd.release(), location, &error_msg));
+ zip_archives_.emplace_back(ZipArchive::OpenFromFd(zip_fd.Release(), location, &error_msg));
ZipArchive* zip_archive = zip_archives_.back().get();
if (zip_archive == nullptr) {
LOG(ERROR) << "Failed to open zip from file descriptor for '" << location << "': "
diff --git a/compiler/oat_writer.h b/compiler/oat_writer.h
index cc81f39..decb7db 100644
--- a/compiler/oat_writer.h
+++ b/compiler/oat_writer.h
@@ -29,7 +29,6 @@
#include "oat.h"
#include "os.h"
#include "safe_map.h"
-#include "ScopedFd.h"
#include "utils/array_ref.h"
namespace art {
@@ -132,7 +131,7 @@
CreateTypeLookupTable create_type_lookup_table = CreateTypeLookupTable::kDefault);
// Add dex file source(s) from a zip file specified by a file handle.
bool AddZippedDexFilesSource(
- ScopedFd&& zip_fd,
+ File&& zip_fd,
const char* location,
CreateTypeLookupTable create_type_lookup_table = CreateTypeLookupTable::kDefault);
// Add dex file source from raw memory.