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

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

Issue 131373002: Fix listing of '' and '/'. (Closed) Base URL: https://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
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/directory.h" 8 #include "bin/directory.h"
9 9
10 #include <dirent.h> // NOLINT 10 #include <dirent.h> // NOLINT
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 LinkList* next; 73 LinkList* next;
74 }; 74 };
75 75
76 76
77 ListType DirectoryListingEntry::Next(DirectoryListing* listing) { 77 ListType DirectoryListingEntry::Next(DirectoryListing* listing) {
78 if (done_) { 78 if (done_) {
79 return kListDone; 79 return kListDone;
80 } 80 }
81 81
82 if (lister_ == 0) { 82 if (lister_ == 0) {
83 if (!listing->path_buffer().Add(File::PathSeparator())) {
84 done_ = true;
85 return kListError;
86 }
87 path_length_ = listing->path_buffer().length();
88 do { 83 do {
89 lister_ = reinterpret_cast<intptr_t>( 84 lister_ = reinterpret_cast<intptr_t>(
90 opendir(listing->path_buffer().AsString())); 85 opendir(listing->path_buffer().AsString()));
91 } while (lister_ == 0 && errno == EINTR); 86 } while (lister_ == 0 && errno == EINTR);
92 87
93 if (lister_ == 0) { 88 if (lister_ == 0) {
94 done_ = true; 89 done_ = true;
95 return kListError; 90 return kListError;
96 } 91 }
92 if (parent_ != NULL) {
93 if (!listing->path_buffer().Add(File::PathSeparator())) {
94 return kListError;
95 }
96 }
97 path_length_ = listing->path_buffer().length();
97 } 98 }
98 // Reset. 99 // Reset.
99 listing->path_buffer().Reset(path_length_); 100 listing->path_buffer().Reset(path_length_);
100 ResetLink(); 101 ResetLink();
101 102
102 // Iterate the directory and post the directories and files to the 103 // Iterate the directory and post the directories and files to the
103 // ports. 104 // ports.
104 int status = 0; 105 int status = 0;
105 dirent entry; 106 dirent entry;
106 dirent* result; 107 dirent* result;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 bool Directory::Rename(const char* path, const char* new_path) { 438 bool Directory::Rename(const char* path, const char* new_path) {
438 ExistsResult exists = Exists(path); 439 ExistsResult exists = Exists(path);
439 if (exists != EXISTS) return false; 440 if (exists != EXISTS) return false;
440 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); 441 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0);
441 } 442 }
442 443
443 } // namespace bin 444 } // namespace bin
444 } // namespace dart 445 } // namespace dart
445 446
446 #endif // defined(TARGET_OS_LINUX) 447 #endif // defined(TARGET_OS_LINUX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698