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

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

Issue 3005883002: [dart:io] Remove double-close from recursive directory delete (Closed)
Patch Set: Created 3 years, 3 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
« no previous file with comments | « no previous file | runtime/bin/directory_fuchsia.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(HOST_OS_ANDROID) 6 #if defined(HOST_OS_ANDROID)
7 7
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 9
10 #include <dirent.h> // NOLINT 10 #include <dirent.h> // NOLINT
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // implementations (including the glibc implementation), concurrent calls to 296 // implementations (including the glibc implementation), concurrent calls to
297 // readdir(3) that specify different directory streams are thread-safe." 297 // readdir(3) that specify different directory streams are thread-safe."
298 dirent* entry = readdir(dir_pointer); 298 dirent* entry = readdir(dir_pointer);
299 if (entry == NULL) { 299 if (entry == NULL) {
300 // Failed to read next directory entry. 300 // Failed to read next directory entry.
301 if (errno != 0) { 301 if (errno != 0) {
302 break; 302 break;
303 } 303 }
304 // End of directory. 304 // End of directory.
305 int status = NO_RETRY_EXPECTED(closedir(dir_pointer)); 305 int status = NO_RETRY_EXPECTED(closedir(dir_pointer));
306 FDUtils::SaveErrorAndClose(fd);
307 if (status != 0) { 306 if (status != 0) {
308 return false; 307 return false;
309 } 308 }
310 status = 309 status =
311 NO_RETRY_EXPECTED(unlinkat(dirfd, path->AsString(), AT_REMOVEDIR)); 310 NO_RETRY_EXPECTED(unlinkat(dirfd, path->AsString(), AT_REMOVEDIR));
312 return status == 0; 311 return status == 0;
313 } 312 }
314 bool ok = false; 313 bool ok = false;
315 switch (entry->d_type) { 314 switch (entry->d_type) {
316 case DT_DIR: 315 case DT_DIR:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 356 }
358 if (!ok) { 357 if (!ok) {
359 break; 358 break;
360 } 359 }
361 path->Reset(path_length); 360 path->Reset(path_length);
362 } 361 }
363 // Only happens if an error. 362 // Only happens if an error.
364 ASSERT(errno != 0); 363 ASSERT(errno != 0);
365 int err = errno; 364 int err = errno;
366 VOID_NO_RETRY_EXPECTED(closedir(dir_pointer)); 365 VOID_NO_RETRY_EXPECTED(closedir(dir_pointer));
367 FDUtils::SaveErrorAndClose(fd);
368 errno = err; 366 errno = err;
369 return false; 367 return false;
370 } 368 }
371 369
372 Directory::ExistsResult Directory::Exists(Namespace* namespc, 370 Directory::ExistsResult Directory::Exists(Namespace* namespc,
373 const char* dir_name) { 371 const char* dir_name) {
374 NamespaceScope ns(namespc, dir_name); 372 NamespaceScope ns(namespc, dir_name);
375 struct stat entry_info; 373 struct stat entry_info;
376 int success = TEMP_FAILURE_RETRY(fstatat(ns.fd(), ns.path(), &entry_info, 0)); 374 int success = TEMP_FAILURE_RETRY(fstatat(ns.fd(), ns.path(), &entry_info, 0));
377 if (success == 0) { 375 if (success == 0) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 NamespaceScope oldns(namespc, old_path); 502 NamespaceScope oldns(namespc, old_path);
505 NamespaceScope newns(namespc, new_path); 503 NamespaceScope newns(namespc, new_path);
506 return (NO_RETRY_EXPECTED(renameat(oldns.fd(), oldns.path(), newns.fd(), 504 return (NO_RETRY_EXPECTED(renameat(oldns.fd(), oldns.path(), newns.fd(),
507 newns.path())) == 0); 505 newns.path())) == 0);
508 } 506 }
509 507
510 } // namespace bin 508 } // namespace bin
511 } // namespace dart 509 } // namespace dart
512 510
513 #endif // defined(HOST_OS_ANDROID) 511 #endif // defined(HOST_OS_ANDROID)
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/directory_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698