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

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

Issue 233053004: Fix File:copy FD leak, and add file-closes to some tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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_android.cc ('k') | tests/standalone/io/file_input_stream_test.dart » ('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_LINUX) 6 #if defined(TARGET_OS_LINUX)
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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 uint8_t buffer[kBufferSize]; 258 uint8_t buffer[kBufferSize];
259 while ((result = TEMP_FAILURE_RETRY( 259 while ((result = TEMP_FAILURE_RETRY(
260 read(old_fd, buffer, kBufferSize))) > 0) { 260 read(old_fd, buffer, kBufferSize))) > 0) {
261 int wrote = TEMP_FAILURE_RETRY(write(new_fd, buffer, result)); 261 int wrote = TEMP_FAILURE_RETRY(write(new_fd, buffer, result));
262 if (wrote != result) { 262 if (wrote != result) {
263 result = -1; 263 result = -1;
264 break; 264 break;
265 } 265 }
266 } 266 }
267 } 267 }
268 int e = errno;
269 VOID_TEMP_FAILURE_RETRY(close(old_fd));
270 VOID_TEMP_FAILURE_RETRY(close(new_fd));
268 if (result < 0) { 271 if (result < 0) {
269 int e = errno;
270 VOID_TEMP_FAILURE_RETRY(close(old_fd));
271 VOID_TEMP_FAILURE_RETRY(close(new_fd));
272 VOID_NO_RETRY_EXPECTED(unlink(new_path)); 272 VOID_NO_RETRY_EXPECTED(unlink(new_path));
273 errno = e; 273 errno = e;
274 return false; 274 return false;
275 } 275 }
276 return true; 276 return true;
277 } else if (type == kIsDirectory) { 277 } else if (type == kIsDirectory) {
278 errno = EISDIR; 278 errno = EISDIR;
279 } else { 279 } else {
280 errno = ENOENT; 280 errno = ENOENT;
281 } 281 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 return (file_1_info.st_ino == file_2_info.st_ino && 415 return (file_1_info.st_ino == file_2_info.st_ino &&
416 file_1_info.st_dev == file_2_info.st_dev) ? 416 file_1_info.st_dev == file_2_info.st_dev) ?
417 File::kIdentical : 417 File::kIdentical :
418 File::kDifferent; 418 File::kDifferent;
419 } 419 }
420 420
421 } // namespace bin 421 } // namespace bin
422 } // namespace dart 422 } // namespace dart
423 423
424 #endif // defined(TARGET_OS_LINUX) 424 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/file_android.cc ('k') | tests/standalone/io/file_input_stream_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698