| 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_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 done_ = true; | 122 done_ = true; |
| 123 return kListError; | 123 return kListError; |
| 124 } | 124 } |
| 125 switch (entry.d_type) { | 125 switch (entry.d_type) { |
| 126 case DT_DIR: | 126 case DT_DIR: |
| 127 if ((strcmp(entry.d_name, ".") == 0) || | 127 if ((strcmp(entry.d_name, ".") == 0) || |
| 128 (strcmp(entry.d_name, "..") == 0)) { | 128 (strcmp(entry.d_name, "..") == 0)) { |
| 129 return Next(listing); | 129 return Next(listing); |
| 130 } | 130 } |
| 131 return kListDirectory; | 131 return kListDirectory; |
| 132 case DT_BLK: |
| 133 case DT_CHR: |
| 134 case DT_FIFO: |
| 135 case DT_SOCK: |
| 132 case DT_REG: | 136 case DT_REG: |
| 133 return kListFile; | 137 return kListFile; |
| 134 case DT_LNK: | 138 case DT_LNK: |
| 135 if (!listing->follow_links()) { | 139 if (!listing->follow_links()) { |
| 136 return kListLink; | 140 return kListLink; |
| 137 } | 141 } |
| 138 // Else fall through to next case. | 142 // Else fall through to next case. |
| 139 // Fall through. | 143 // Fall through. |
| 140 case DT_UNKNOWN: { | 144 case DT_UNKNOWN: { |
| 141 // On some file systems the entry type is not determined by | 145 // On some file systems the entry type is not determined by |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 181 } |
| 178 return kListDirectory; | 182 return kListDirectory; |
| 179 } | 183 } |
| 180 } | 184 } |
| 181 if (S_ISDIR(entry_info.st_mode)) { | 185 if (S_ISDIR(entry_info.st_mode)) { |
| 182 if ((strcmp(entry.d_name, ".") == 0) || | 186 if ((strcmp(entry.d_name, ".") == 0) || |
| 183 (strcmp(entry.d_name, "..") == 0)) { | 187 (strcmp(entry.d_name, "..") == 0)) { |
| 184 return Next(listing); | 188 return Next(listing); |
| 185 } | 189 } |
| 186 return kListDirectory; | 190 return kListDirectory; |
| 187 } else if (S_ISREG(entry_info.st_mode)) { | 191 } else if (S_ISREG(entry_info.st_mode) || S_ISCHR(entry_info.st_mode) || |
| 192 S_ISBLK(entry_info.st_mode) || |
| 193 S_ISFIFO(entry_info.st_mode) || |
| 194 S_ISSOCK(entry_info.st_mode)) { |
| 188 return kListFile; | 195 return kListFile; |
| 189 } else if (S_ISLNK(entry_info.st_mode)) { | 196 } else if (S_ISLNK(entry_info.st_mode)) { |
| 190 return kListLink; | 197 return kListLink; |
| 198 } else { |
| 199 FATAL1("Unexpected st_mode: %d\n", entry_info.st_mode); |
| 200 return kListError; |
| 191 } | 201 } |
| 192 } | 202 } |
| 193 | 203 |
| 194 default: | 204 default: |
| 195 break; | 205 // We should have covered all the bases. If not, let's get an error. |
| 206 FATAL1("Unexpected d_type: %d\n", entry.d_type); |
| 207 return kListError; |
| 196 } | 208 } |
| 197 } | 209 } |
| 198 done_ = true; | 210 done_ = true; |
| 199 | 211 |
| 200 if (status != 0) { | 212 if (status != 0) { |
| 201 errno = status; | 213 errno = status; |
| 202 return kListError; | 214 return kListError; |
| 203 } | 215 } |
| 204 | 216 |
| 205 return kListDone; | 217 return kListDone; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 if (exists != EXISTS) { | 462 if (exists != EXISTS) { |
| 451 return false; | 463 return false; |
| 452 } | 464 } |
| 453 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); | 465 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); |
| 454 } | 466 } |
| 455 | 467 |
| 456 } // namespace bin | 468 } // namespace bin |
| 457 } // namespace dart | 469 } // namespace dart |
| 458 | 470 |
| 459 #endif // defined(TARGET_OS_MACOS) | 471 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |