| Index: runtime/bin/file_fuchsia.cc
|
| diff --git a/runtime/bin/file_fuchsia.cc b/runtime/bin/file_fuchsia.cc
|
| index ad5cb45d674efd973d04186db99c51a4ae25ace9..cc36ea9f7dab661e5b2d28ccb64578d9f2f6d3d8 100644
|
| --- a/runtime/bin/file_fuchsia.cc
|
| +++ b/runtime/bin/file_fuchsia.cc
|
| @@ -38,7 +38,6 @@ class FileHandle {
|
| DISALLOW_COPY_AND_ASSIGN(FileHandle);
|
| };
|
|
|
| -
|
| File::~File() {
|
| if (!IsClosed()) {
|
| Close();
|
| @@ -46,7 +45,6 @@ File::~File() {
|
| delete handle_;
|
| }
|
|
|
| -
|
| void File::Close() {
|
| ASSERT(handle_->fd() >= 0);
|
| if (handle_->fd() == STDOUT_FILENO) {
|
| @@ -66,40 +64,33 @@ void File::Close() {
|
| handle_->set_fd(kClosedFd);
|
| }
|
|
|
| -
|
| intptr_t File::GetFD() {
|
| return handle_->fd();
|
| }
|
|
|
| -
|
| bool File::IsClosed() {
|
| return handle_->fd() == kClosedFd;
|
| }
|
|
|
| -
|
| MappedMemory* File::Map(MapType type, int64_t position, int64_t length) {
|
| UNIMPLEMENTED();
|
| return NULL;
|
| }
|
|
|
| -
|
| void MappedMemory::Unmap() {
|
| UNIMPLEMENTED();
|
| }
|
|
|
| -
|
| int64_t File::Read(void* buffer, int64_t num_bytes) {
|
| ASSERT(handle_->fd() >= 0);
|
| return NO_RETRY_EXPECTED(read(handle_->fd(), buffer, num_bytes));
|
| }
|
|
|
| -
|
| int64_t File::Write(const void* buffer, int64_t num_bytes) {
|
| ASSERT(handle_->fd() >= 0);
|
| return NO_RETRY_EXPECTED(write(handle_->fd(), buffer, num_bytes));
|
| }
|
|
|
| -
|
| bool File::VPrint(const char* format, va_list args) {
|
| // Measure.
|
| va_list measure_args;
|
| @@ -120,31 +111,26 @@ bool File::VPrint(const char* format, va_list args) {
|
| return result;
|
| }
|
|
|
| -
|
| int64_t File::Position() {
|
| ASSERT(handle_->fd() >= 0);
|
| return NO_RETRY_EXPECTED(lseek(handle_->fd(), 0, SEEK_CUR));
|
| }
|
|
|
| -
|
| bool File::SetPosition(int64_t position) {
|
| ASSERT(handle_->fd() >= 0);
|
| return NO_RETRY_EXPECTED(lseek(handle_->fd(), position, SEEK_SET)) >= 0;
|
| }
|
|
|
| -
|
| bool File::Truncate(int64_t length) {
|
| ASSERT(handle_->fd() >= 0);
|
| return NO_RETRY_EXPECTED(ftruncate(handle_->fd(), length) != -1);
|
| }
|
|
|
| -
|
| bool File::Flush() {
|
| ASSERT(handle_->fd() >= 0);
|
| return NO_RETRY_EXPECTED(fsync(handle_->fd())) != -1;
|
| }
|
|
|
| -
|
| bool File::Lock(File::LockType lock, int64_t start, int64_t end) {
|
| ASSERT(handle_->fd() >= 0);
|
| ASSERT((end == -1) || (end > start));
|
| @@ -175,7 +161,6 @@ bool File::Lock(File::LockType lock, int64_t start, int64_t end) {
|
| return NO_RETRY_EXPECTED(fcntl(handle_->fd(), cmd, &fl)) != -1;
|
| }
|
|
|
| -
|
| int64_t File::Length() {
|
| ASSERT(handle_->fd() >= 0);
|
| struct stat st;
|
| @@ -185,13 +170,11 @@ int64_t File::Length() {
|
| return -1;
|
| }
|
|
|
| -
|
| File* File::FileOpenW(const wchar_t* system_name, FileOpenMode mode) {
|
| UNREACHABLE();
|
| return NULL;
|
| }
|
|
|
| -
|
| File* File::Open(const char* name, FileOpenMode mode) {
|
| // Report errors for non-regular files.
|
| struct stat st;
|
| @@ -228,12 +211,10 @@ File* File::Open(const char* name, FileOpenMode mode) {
|
| return new File(new FileHandle(fd));
|
| }
|
|
|
| -
|
| File* File::OpenStdio(int fd) {
|
| return ((fd < 0) || (2 < fd)) ? NULL : new File(new FileHandle(fd));
|
| }
|
|
|
| -
|
| bool File::Exists(const char* name) {
|
| struct stat64 st;
|
| if (NO_RETRY_EXPECTED(stat64(name, &st)) == 0) {
|
| @@ -244,7 +225,6 @@ bool File::Exists(const char* name) {
|
| }
|
| }
|
|
|
| -
|
| bool File::Create(const char* name) {
|
| int fd =
|
| NO_RETRY_EXPECTED(open64(name, O_RDONLY | O_CREAT | O_CLOEXEC, 0666));
|
| @@ -269,12 +249,10 @@ bool File::Create(const char* name) {
|
| return is_file;
|
| }
|
|
|
| -
|
| bool File::CreateLink(const char* name, const char* target) {
|
| return NO_RETRY_EXPECTED(symlink(target, name)) == 0;
|
| }
|
|
|
| -
|
| File::Type File::GetType(const char* pathname, bool follow_links) {
|
| struct stat entry_info;
|
| int stat_success;
|
| @@ -298,7 +276,6 @@ File::Type File::GetType(const char* pathname, bool follow_links) {
|
| return File::kDoesNotExist;
|
| }
|
|
|
| -
|
| static bool CheckTypeAndSetErrno(const char* name,
|
| File::Type expected,
|
| bool follow_links) {
|
| @@ -320,31 +297,26 @@ static bool CheckTypeAndSetErrno(const char* name,
|
| return false;
|
| }
|
|
|
| -
|
| bool File::Delete(const char* name) {
|
| return CheckTypeAndSetErrno(name, kIsFile, true) &&
|
| (NO_RETRY_EXPECTED(unlink(name)) == 0);
|
| }
|
|
|
| -
|
| bool File::DeleteLink(const char* name) {
|
| return CheckTypeAndSetErrno(name, kIsLink, false) &&
|
| (NO_RETRY_EXPECTED(unlink(name)) == 0);
|
| }
|
|
|
| -
|
| bool File::Rename(const char* old_path, const char* new_path) {
|
| return CheckTypeAndSetErrno(old_path, kIsFile, true) &&
|
| (NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0);
|
| }
|
|
|
| -
|
| bool File::RenameLink(const char* old_path, const char* new_path) {
|
| return CheckTypeAndSetErrno(old_path, kIsLink, false) &&
|
| (NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0);
|
| }
|
|
|
| -
|
| bool File::Copy(const char* old_path, const char* new_path) {
|
| if (!CheckTypeAndSetErrno(old_path, kIsFile, true)) {
|
| return false;
|
| @@ -385,7 +357,6 @@ bool File::Copy(const char* old_path, const char* new_path) {
|
| return true;
|
| }
|
|
|
| -
|
| static bool StatHelper(const char* name, struct stat64* st) {
|
| if (NO_RETRY_EXPECTED(stat64(name, st)) != 0) {
|
| return false;
|
| @@ -399,7 +370,6 @@ static bool StatHelper(const char* name, struct stat64* st) {
|
| return true;
|
| }
|
|
|
| -
|
| int64_t File::LengthFromPath(const char* name) {
|
| struct stat64 st;
|
| if (!StatHelper(name, &st)) {
|
| @@ -408,7 +378,6 @@ int64_t File::LengthFromPath(const char* name) {
|
| return st.st_size;
|
| }
|
|
|
| -
|
| void File::Stat(const char* name, int64_t* data) {
|
| struct stat st;
|
| if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
|
| @@ -431,7 +400,6 @@ void File::Stat(const char* name, int64_t* data) {
|
| }
|
| }
|
|
|
| -
|
| time_t File::LastModified(const char* name) {
|
| struct stat st;
|
| if (!StatHelper(name, &st)) {
|
| @@ -440,7 +408,6 @@ time_t File::LastModified(const char* name) {
|
| return st.st_mtime;
|
| }
|
|
|
| -
|
| time_t File::LastAccessed(const char* name) {
|
| struct stat st;
|
| if (!StatHelper(name, &st)) {
|
| @@ -449,7 +416,6 @@ time_t File::LastAccessed(const char* name) {
|
| return st.st_atime;
|
| }
|
|
|
| -
|
| bool File::SetLastAccessed(const char* name, int64_t millis) {
|
| // First get the current times.
|
| struct stat st;
|
| @@ -464,7 +430,6 @@ bool File::SetLastAccessed(const char* name, int64_t millis) {
|
| return utime(name, ×) == 0;
|
| }
|
|
|
| -
|
| bool File::SetLastModified(const char* name, int64_t millis) {
|
| // First get the current times.
|
| struct stat st;
|
| @@ -479,7 +444,6 @@ bool File::SetLastModified(const char* name, int64_t millis) {
|
| return utime(name, ×) == 0;
|
| }
|
|
|
| -
|
| const char* File::LinkTarget(const char* pathname) {
|
| struct stat link_stats;
|
| if (lstat(pathname, &link_stats) != 0) {
|
| @@ -500,12 +464,10 @@ const char* File::LinkTarget(const char* pathname) {
|
| return target_name;
|
| }
|
|
|
| -
|
| bool File::IsAbsolutePath(const char* pathname) {
|
| return ((pathname != NULL) && (pathname[0] == '/'));
|
| }
|
|
|
| -
|
| const char* File::GetCanonicalPath(const char* pathname) {
|
| char* abs_path = NULL;
|
| if (pathname != NULL) {
|
| @@ -518,17 +480,14 @@ const char* File::GetCanonicalPath(const char* pathname) {
|
| return abs_path;
|
| }
|
|
|
| -
|
| const char* File::PathSeparator() {
|
| return "/";
|
| }
|
|
|
| -
|
| const char* File::StringEscapedPathSeparator() {
|
| return "/";
|
| }
|
|
|
| -
|
| File::StdioHandleType File::GetStdioHandleType(int fd) {
|
| ASSERT((0 <= fd) && (fd <= 2));
|
| struct stat buf;
|
| @@ -551,7 +510,6 @@ File::StdioHandleType File::GetStdioHandleType(int fd) {
|
| return kOther;
|
| }
|
|
|
| -
|
| File::Identical File::AreIdentical(const char* file_1, const char* file_2) {
|
| struct stat file_1_info;
|
| struct stat file_2_info;
|
|
|