From c431b9dc4b23cc950eb313695258df5d89f53b22 Mon Sep 17 00:00:00 2001 From: David Sehr Date: Fri, 2 Mar 2018 12:01:51 -0800 Subject: Move most of runtime/base to libartbase/base Enforce the layering that code in runtime/base should not depend on runtime by separating it into libartbase. Some of the code in runtime/base depends on the Runtime class, so it cannot be moved yet. Also, some of the tests depend on CommonRuntimeTest, which itself needs to be factored (in a subsequent CL). Bug: 22322814 Test: make -j 50 checkbuild make -j 50 test-art-host Change-Id: I8b096c1e2542f829eb456b4b057c71421b77d7e2 --- runtime/base/file_utils.cc | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) (limited to 'runtime/base/file_utils.cc') diff --git a/runtime/base/file_utils.cc b/runtime/base/file_utils.cc index dd3f8d5b3c..f9d0d12d88 100644 --- a/runtime/base/file_utils.cc +++ b/runtime/base/file_utils.cc @@ -17,10 +17,7 @@ #include "file_utils.h" #include -#include -#include // For madvise #include -#include #include #include #include @@ -47,10 +44,10 @@ #include "base/bit_utils.h" #include "base/stl_util.h" +#include "base/os.h" #include "base/unix_file/fd_file.h" #include "dex/dex_file_loader.h" #include "globals.h" -#include "os.h" #if defined(__APPLE__) #include @@ -308,19 +305,6 @@ std::string GetSystemImageFilename(const char* location, const InstructionSet is return filename; } -bool FileExists(const std::string& filename) { - struct stat buffer; - return stat(filename.c_str(), &buffer) == 0; -} - -bool FileExistsAndNotEmpty(const std::string& filename) { - struct stat buffer; - if (stat(filename.c_str(), &buffer) != 0) { - return false; - } - return buffer.st_size > 0; -} - std::string ReplaceFileExtension(const std::string& filename, const std::string& new_extension) { const size_t last_ext = filename.find_last_of('.'); if (last_ext == std::string::npos) { @@ -330,26 +314,6 @@ std::string ReplaceFileExtension(const std::string& filename, const std::string& } } -int64_t GetFileSizeBytes(const std::string& filename) { - struct stat stat_buf; - int rc = stat(filename.c_str(), &stat_buf); - return rc == 0 ? stat_buf.st_size : -1; -} - -int MadviseLargestPageAlignedRegion(const uint8_t* begin, const uint8_t* end, int advice) { - DCHECK_LE(begin, end); - begin = AlignUp(begin, kPageSize); - end = AlignDown(end, kPageSize); - if (begin < end) { - int result = madvise(const_cast(begin), end - begin, advice); - if (result != 0) { - PLOG(WARNING) << "madvise failed " << result; - } - return result; - } - return 0; -} - bool LocationIsOnSystem(const char* location) { UniqueCPtr path(realpath(location, nullptr)); return path != nullptr && android::base::StartsWith(path.get(), GetAndroidRoot().c_str()); -- cgit v1.2.3-59-g8ed1b