| Index: runtime/bin/file_macos.cc
|
| diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc
|
| index e491f34f900f39d2e27c3d962bb96a844a72d7cf..98d93e617ce6fc335b592a22f0d1b4d01b2e71ae 100644
|
| --- a/runtime/bin/file_macos.cc
|
| +++ b/runtime/bin/file_macos.cc
|
| @@ -94,14 +94,11 @@ bool File::Flush() {
|
|
|
| off_t File::Length() {
|
| ASSERT(handle_->fd() >= 0);
|
| - off_t position = TEMP_FAILURE_RETRY(lseek(handle_->fd(), 0, SEEK_CUR));
|
| - if (position < 0) {
|
| - // The file is not capable of seeking. Return an error.
|
| - return -1;
|
| + struct stat st;
|
| + if (TEMP_FAILURE_RETRY(fstat(handle_->fd(), &st)) == 0) {
|
| + return st.st_size;
|
| }
|
| - off_t result = TEMP_FAILURE_RETRY(lseek(handle_->fd(), 0, SEEK_END));
|
| - TEMP_FAILURE_RETRY(lseek(handle_->fd(), position, SEEK_SET));
|
| - return result;
|
| + return -1;
|
| }
|
|
|
|
|
| @@ -169,6 +166,15 @@ bool File::Delete(const char* name) {
|
| }
|
|
|
|
|
| +off_t File::LengthFromName(const char* name) {
|
| + struct stat st;
|
| + if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
|
| + return st.st_size;
|
| + }
|
| + return -1;
|
| +}
|
| +
|
| +
|
| bool File::IsAbsolutePath(const char* pathname) {
|
| return (pathname != NULL && pathname[0] == '/');
|
| }
|
|
|