Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: runtime/bin/file_android.cc

Issue 139043003: - Address warnings about 64-bit to 32-bit conversions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file.cc ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 73
74 int64_t File::Write(const void* buffer, int64_t num_bytes) { 74 int64_t File::Write(const void* buffer, int64_t num_bytes) {
75 ASSERT(handle_->fd() >= 0); 75 ASSERT(handle_->fd() >= 0);
76 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(write(handle_->fd(), buffer, 76 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(write(handle_->fd(), buffer,
77 num_bytes)); 77 num_bytes));
78 } 78 }
79 79
80 80
81 off64_t File::Position() { 81 int64_t File::Position() {
82 ASSERT(handle_->fd() >= 0); 82 ASSERT(handle_->fd() >= 0);
83 return lseek64(handle_->fd(), 0, SEEK_CUR); 83 return lseek64(handle_->fd(), 0, SEEK_CUR);
84 } 84 }
85 85
86 86
87 bool File::SetPosition(off64_t position) { 87 bool File::SetPosition(int64_t position) {
88 ASSERT(handle_->fd() >= 0); 88 ASSERT(handle_->fd() >= 0);
89 return lseek64(handle_->fd(), position, SEEK_SET) >= 0; 89 return lseek64(handle_->fd(), position, SEEK_SET) >= 0;
90 } 90 }
91 91
92 92
93 bool File::Truncate(off64_t length) { 93 bool File::Truncate(int64_t length) {
94 ASSERT(handle_->fd() >= 0); 94 ASSERT(handle_->fd() >= 0);
95 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS( 95 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(
96 ftruncate(handle_->fd(), length) != -1); 96 ftruncate(handle_->fd(), length) != -1);
97 } 97 }
98 98
99 99
100 bool File::Flush() { 100 bool File::Flush() {
101 ASSERT(handle_->fd() >= 0); 101 ASSERT(handle_->fd() >= 0);
102 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(fsync(handle_->fd()) != -1); 102 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(fsync(handle_->fd()) != -1);
103 } 103 }
104 104
105 105
106 off64_t File::Length() { 106 int64_t File::Length() {
107 ASSERT(handle_->fd() >= 0); 107 ASSERT(handle_->fd() >= 0);
108 struct stat st; 108 struct stat st;
109 if (TEMP_FAILURE_RETRY_BLOCK_SIGNALS(fstat(handle_->fd(), &st)) == 0) { 109 if (TEMP_FAILURE_RETRY_BLOCK_SIGNALS(fstat(handle_->fd(), &st)) == 0) {
110 return st.st_size; 110 return st.st_size;
111 } 111 }
112 return -1; 112 return -1;
113 } 113 }
114 114
115 115
116 File* File::Open(const char* name, FileOpenMode mode) { 116 File* File::Open(const char* name, FileOpenMode mode) {
(...skipping 11 matching lines...) Expand all
128 } 128 }
129 if ((mode & kTruncate) != 0) { 129 if ((mode & kTruncate) != 0) {
130 flags = flags | O_TRUNC; 130 flags = flags | O_TRUNC;
131 } 131 }
132 flags |= O_CLOEXEC; 132 flags |= O_CLOEXEC;
133 int fd = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(open(name, flags, 0666)); 133 int fd = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(open(name, flags, 0666));
134 if (fd < 0) { 134 if (fd < 0) {
135 return NULL; 135 return NULL;
136 } 136 }
137 if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) { 137 if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) {
138 off64_t position = lseek64(fd, 0, SEEK_END); 138 int64_t position = lseek64(fd, 0, SEEK_END);
139 if (position < 0) { 139 if (position < 0) {
140 return NULL; 140 return NULL;
141 } 141 }
142 } 142 }
143 return new File(new FileHandle(fd)); 143 return new File(new FileHandle(fd));
144 } 144 }
145 145
146 146
147 File* File::OpenStdio(int fd) { 147 File* File::OpenStdio(int fd) {
148 if (fd < 0 || 2 < fd) return NULL; 148 if (fd < 0 || 2 < fd) return NULL;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 return true; 278 return true;
279 } else if (type == kIsDirectory) { 279 } else if (type == kIsDirectory) {
280 errno = EISDIR; 280 errno = EISDIR;
281 } else { 281 } else {
282 errno = ENOENT; 282 errno = ENOENT;
283 } 283 }
284 return false; 284 return false;
285 } 285 }
286 286
287 287
288 off64_t File::LengthFromPath(const char* name) { 288 int64_t File::LengthFromPath(const char* name) {
289 struct stat st; 289 struct stat st;
290 if (TEMP_FAILURE_RETRY_BLOCK_SIGNALS(stat(name, &st)) == 0) { 290 if (TEMP_FAILURE_RETRY_BLOCK_SIGNALS(stat(name, &st)) == 0) {
291 return st.st_size; 291 return st.st_size;
292 } 292 }
293 return -1; 293 return -1;
294 } 294 }
295 295
296 296
297 void File::Stat(const char* name, int64_t* data) { 297 void File::Stat(const char* name, int64_t* data) {
298 struct stat st; 298 struct stat st;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 return (file_1_info.st_ino == file_2_info.st_ino && 425 return (file_1_info.st_ino == file_2_info.st_ino &&
426 file_1_info.st_dev == file_2_info.st_dev) ? 426 file_1_info.st_dev == file_2_info.st_dev) ?
427 File::kIdentical : 427 File::kIdentical :
428 File::kDifferent; 428 File::kDifferent;
429 } 429 }
430 430
431 } // namespace bin 431 } // namespace bin
432 } // namespace dart 432 } // namespace dart
433 433
434 #endif // defined(TARGET_OS_ANDROID) 434 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/file.cc ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698