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

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

Issue 2556313002: Handle non-regular file types in the directory lister (Closed)
Patch Set: Fix typos Created 4 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
« no previous file with comments | « runtime/bin/directory_android.cc ('k') | runtime/bin/directory_macos.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_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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 done_ = true; 120 done_ = true;
121 return kListError; 121 return kListError;
122 } 122 }
123 switch (entry->d_type) { 123 switch (entry->d_type) {
124 case DT_DIR: 124 case DT_DIR:
125 if ((strcmp(entry->d_name, ".") == 0) || 125 if ((strcmp(entry->d_name, ".") == 0) ||
126 (strcmp(entry->d_name, "..") == 0)) { 126 (strcmp(entry->d_name, "..") == 0)) {
127 return Next(listing); 127 return Next(listing);
128 } 128 }
129 return kListDirectory; 129 return kListDirectory;
130 case DT_BLK:
131 case DT_CHR:
132 case DT_FIFO:
133 case DT_SOCK:
130 case DT_REG: 134 case DT_REG:
131 return kListFile; 135 return kListFile;
132 case DT_LNK: 136 case DT_LNK:
133 if (!listing->follow_links()) { 137 if (!listing->follow_links()) {
134 return kListLink; 138 return kListLink;
135 } 139 }
136 // Else fall through to next case. 140 // Else fall through to next case.
137 // Fall through. 141 // Fall through.
138 case DT_UNKNOWN: { 142 case DT_UNKNOWN: {
139 // On some file systems the entry type is not determined by 143 // On some file systems the entry type is not determined by
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 179 }
176 return kListDirectory; 180 return kListDirectory;
177 } 181 }
178 } 182 }
179 if (S_ISDIR(entry_info.st_mode)) { 183 if (S_ISDIR(entry_info.st_mode)) {
180 if ((strcmp(entry->d_name, ".") == 0) || 184 if ((strcmp(entry->d_name, ".") == 0) ||
181 (strcmp(entry->d_name, "..") == 0)) { 185 (strcmp(entry->d_name, "..") == 0)) {
182 return Next(listing); 186 return Next(listing);
183 } 187 }
184 return kListDirectory; 188 return kListDirectory;
185 } else if (S_ISREG(entry_info.st_mode)) { 189 } else if (S_ISREG(entry_info.st_mode) || S_ISCHR(entry_info.st_mode) ||
190 S_ISBLK(entry_info.st_mode) ||
191 S_ISFIFO(entry_info.st_mode) ||
192 S_ISSOCK(entry_info.st_mode)) {
186 return kListFile; 193 return kListFile;
187 } else if (S_ISLNK(entry_info.st_mode)) { 194 } else if (S_ISLNK(entry_info.st_mode)) {
188 return kListLink; 195 return kListLink;
196 } else {
197 FATAL1("Unexpected st_mode: %d\n", entry_info.st_mode);
198 return kListError;
189 } 199 }
190 } 200 }
191 201
192 default: 202 default:
193 break; 203 // We should have covered all the bases. If not, let's get an error.
204 FATAL1("Unexpected d_type: %d\n", entry->d_type);
205 return kListError;
194 } 206 }
195 } 207 }
196 done_ = true; 208 done_ = true;
197 209
198 if (errno != 0) { 210 if (errno != 0) {
199 return kListError; 211 return kListError;
200 } 212 }
201 213
202 return kListDone; 214 return kListDone;
203 } 215 }
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (exists != EXISTS) { 471 if (exists != EXISTS) {
460 return false; 472 return false;
461 } 473 }
462 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); 474 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0);
463 } 475 }
464 476
465 } // namespace bin 477 } // namespace bin
466 } // namespace dart 478 } // namespace dart
467 479
468 #endif // defined(TARGET_OS_LINUX) 480 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/directory_android.cc ('k') | runtime/bin/directory_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698