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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 if (pathname != NULL) { | 268 if (pathname != NULL) { |
269 do { | 269 do { |
270 abs_path = realpath(pathname, NULL); | 270 abs_path = realpath(pathname, NULL); |
271 } while (abs_path == NULL && errno == EINTR); | 271 } while (abs_path == NULL && errno == EINTR); |
272 ASSERT(abs_path == NULL || IsAbsolutePath(abs_path)); | 272 ASSERT(abs_path == NULL || IsAbsolutePath(abs_path)); |
273 } | 273 } |
274 return abs_path; | 274 return abs_path; |
275 } | 275 } |
276 | 276 |
277 | 277 |
278 char* File::GetContainingDirectory(char* pathname) { | |
279 // Report errors for non-regular files. | |
280 struct stat st; | |
281 if (TEMP_FAILURE_RETRY(stat(pathname, &st)) == 0) { | |
282 if (!S_ISREG(st.st_mode)) { | |
283 errno = (S_ISDIR(st.st_mode)) ? EISDIR : ENOENT; | |
284 return NULL; | |
285 } | |
286 } else { | |
287 return NULL; | |
288 } | |
289 char* path = NULL; | |
290 do { | |
291 path = dirname(pathname); | |
292 } while (path == NULL && errno == EINTR); | |
293 return GetCanonicalPath(path); | |
294 } | |
295 | |
296 | |
297 const char* File::PathSeparator() { | 278 const char* File::PathSeparator() { |
298 return "/"; | 279 return "/"; |
299 } | 280 } |
300 | 281 |
301 | 282 |
302 const char* File::StringEscapedPathSeparator() { | 283 const char* File::StringEscapedPathSeparator() { |
303 return "/"; | 284 return "/"; |
304 } | 285 } |
305 | 286 |
306 | 287 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 return (file_1_info.st_ino == file_2_info.st_ino && | 326 return (file_1_info.st_ino == file_2_info.st_ino && |
346 file_1_info.st_dev == file_2_info.st_dev) ? | 327 file_1_info.st_dev == file_2_info.st_dev) ? |
347 File::kIdentical : | 328 File::kIdentical : |
348 File::kDifferent; | 329 File::kDifferent; |
349 } | 330 } |
350 | 331 |
351 } // namespace bin | 332 } // namespace bin |
352 } // namespace dart | 333 } // namespace dart |
353 | 334 |
354 #endif // defined(TARGET_OS_LINUX) | 335 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |