OLD | NEW |
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 Loading... |
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 Loading... |
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) |
OLD | NEW |