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

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

Issue 102663005: Add comment to File copy on linux/android. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | « no previous file | 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 VOID_TEMP_FAILURE_RETRY(close(old_fd)); 237 VOID_TEMP_FAILURE_RETRY(close(old_fd));
238 return false; 238 return false;
239 } 239 }
240 off_t offset = 0; 240 off_t offset = 0;
241 int result = 1; 241 int result = 1;
242 while (result > 0) { 242 while (result > 0) {
243 // Loop to ensure we copy everything, and not only up to 2GB. 243 // Loop to ensure we copy everything, and not only up to 2GB.
244 result = TEMP_FAILURE_RETRY( 244 result = TEMP_FAILURE_RETRY(
245 sendfile(new_fd, old_fd, &offset, kMaxUint32)); 245 sendfile(new_fd, old_fd, &offset, kMaxUint32));
246 } 246 }
247 // From sendfile man pages:
248 // Applications may wish to fall back to read(2)/write(2) in the case
249 // where sendfile() fails with EINVAL or ENOSYS.
247 if (result < 0 && (errno == EINVAL || errno == ENOSYS)) { 250 if (result < 0 && (errno == EINVAL || errno == ENOSYS)) {
248 const intptr_t kBufferSize = 8 * 1024; 251 const intptr_t kBufferSize = 8 * KB;
249 uint8_t buffer[kBufferSize]; 252 uint8_t buffer[kBufferSize];
250 while ((result = TEMP_FAILURE_RETRY( 253 while ((result = TEMP_FAILURE_RETRY(
251 read(old_fd, buffer, kBufferSize))) > 0) { 254 read(old_fd, buffer, kBufferSize))) > 0) {
252 int wrote = TEMP_FAILURE_RETRY(write(new_fd, buffer, result)); 255 int wrote = TEMP_FAILURE_RETRY(write(new_fd, buffer, result));
253 if (wrote != result) { 256 if (wrote != result) {
254 result = -1; 257 result = -1;
255 break; 258 break;
256 } 259 }
257 } 260 }
258 } 261 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 return (file_1_info.st_ino == file_2_info.st_ino && 415 return (file_1_info.st_ino == file_2_info.st_ino &&
413 file_1_info.st_dev == file_2_info.st_dev) ? 416 file_1_info.st_dev == file_2_info.st_dev) ?
414 File::kIdentical : 417 File::kIdentical :
415 File::kDifferent; 418 File::kDifferent;
416 } 419 }
417 420
418 } // namespace bin 421 } // namespace bin
419 } // namespace dart 422 } // namespace dart
420 423
421 #endif // defined(TARGET_OS_ANDROID) 424 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/file_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698