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/file.h" | 8 #include "bin/file.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 ASSERT(resolved_path != NULL); | 276 ASSERT(resolved_path != NULL); |
277 do { | 277 do { |
278 abs_path = realpath(pathname, NULL); | 278 abs_path = realpath(pathname, NULL); |
279 } while (abs_path == NULL && errno == EINTR); | 279 } while (abs_path == NULL && errno == EINTR); |
280 ASSERT(abs_path == NULL || IsAbsolutePath(abs_path)); | 280 ASSERT(abs_path == NULL || IsAbsolutePath(abs_path)); |
281 } | 281 } |
282 return abs_path; | 282 return abs_path; |
283 } | 283 } |
284 | 284 |
285 | 285 |
286 char* File::GetContainingDirectory(char* pathname) { | |
287 // Report errors for non-regular files. | |
288 struct stat st; | |
289 if (TEMP_FAILURE_RETRY(stat(pathname, &st)) == 0) { | |
290 if (!S_ISREG(st.st_mode)) { | |
291 errno = (S_ISDIR(st.st_mode)) ? EISDIR : ENOENT; | |
292 return NULL; | |
293 } | |
294 } else { | |
295 return NULL; | |
296 } | |
297 char* path = NULL; | |
298 do { | |
299 path = dirname(pathname); | |
300 } while (path == NULL && errno == EINTR); | |
301 return GetCanonicalPath(path); | |
302 } | |
303 | |
304 | |
305 const char* File::PathSeparator() { | 286 const char* File::PathSeparator() { |
306 return "/"; | 287 return "/"; |
307 } | 288 } |
308 | 289 |
309 | 290 |
310 const char* File::StringEscapedPathSeparator() { | 291 const char* File::StringEscapedPathSeparator() { |
311 return "/"; | 292 return "/"; |
312 } | 293 } |
313 | 294 |
314 | 295 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 return (file_1_info.st_ino == file_2_info.st_ino && | 334 return (file_1_info.st_ino == file_2_info.st_ino && |
354 file_1_info.st_dev == file_2_info.st_dev) ? | 335 file_1_info.st_dev == file_2_info.st_dev) ? |
355 File::kIdentical : | 336 File::kIdentical : |
356 File::kDifferent; | 337 File::kDifferent; |
357 } | 338 } |
358 | 339 |
359 } // namespace bin | 340 } // namespace bin |
360 } // namespace dart | 341 } // namespace dart |
361 | 342 |
362 #endif // defined(TARGET_OS_MACOS) | 343 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |