Chromium Code Reviews| 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_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 | 258 |
| 259 | 259 |
| 260 bool File::IsAbsolutePath(const char* pathname) { | 260 bool File::IsAbsolutePath(const char* pathname) { |
| 261 return (pathname != NULL && pathname[0] == '/'); | 261 return (pathname != NULL && pathname[0] == '/'); |
| 262 } | 262 } |
| 263 | 263 |
| 264 | 264 |
| 265 char* File::GetCanonicalPath(const char* pathname) { | 265 char* File::GetCanonicalPath(const char* pathname) { |
| 266 char* abs_path = NULL; | 266 char* abs_path = NULL; |
| 267 if (pathname != NULL) { | 267 if (pathname != NULL) { |
| 268 // A null second argument to realpath crashes Android. Fixed in Mar 2013, | |
| 269 // but not in earlier releases of Android. | |
| 270 char* resolved = reinterpret_cast<char*>(malloc(PATH_MAX)); | |
| 271 if (resolved == NULL) return (NULL); | |
|
Søren Gjesse
2013/05/28 12:05:32
Remove parentheses around NULL.
Bill Hesse
2013/05/28 12:57:50
Done.
| |
| 268 do { | 272 do { |
| 269 abs_path = realpath(pathname, NULL); | 273 abs_path = realpath(pathname, resolved); |
| 270 } while (abs_path == NULL && errno == EINTR); | 274 } while (abs_path == NULL && errno == EINTR); |
| 271 ASSERT(abs_path == NULL || IsAbsolutePath(abs_path)); | 275 ASSERT(abs_path == NULL || IsAbsolutePath(abs_path)); |
| 276 if (abs_path != resolved) { | |
| 277 free(resolved); | |
| 278 } | |
| 272 } | 279 } |
| 273 return abs_path; | 280 return abs_path; |
| 274 } | 281 } |
| 275 | 282 |
| 276 | 283 |
| 277 char* File::GetContainingDirectory(char* pathname) { | 284 char* File::GetContainingDirectory(char* pathname) { |
| 278 // Report errors for non-regular files. | 285 // Report errors for non-regular files. |
| 279 struct stat st; | 286 struct stat st; |
| 280 if (TEMP_FAILURE_RETRY(stat(pathname, &st)) == 0) { | 287 if (TEMP_FAILURE_RETRY(stat(pathname, &st)) == 0) { |
| 281 if (!S_ISREG(st.st_mode)) { | 288 if (!S_ISREG(st.st_mode)) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 return (file_1_info.st_ino == file_2_info.st_ino && | 351 return (file_1_info.st_ino == file_2_info.st_ino && |
| 345 file_1_info.st_dev == file_2_info.st_dev) ? | 352 file_1_info.st_dev == file_2_info.st_dev) ? |
| 346 File::kIdentical : | 353 File::kIdentical : |
| 347 File::kDifferent; | 354 File::kDifferent; |
| 348 } | 355 } |
| 349 | 356 |
| 350 } // namespace bin | 357 } // namespace bin |
| 351 } // namespace dart | 358 } // namespace dart |
| 352 | 359 |
| 353 #endif // defined(TARGET_OS_ANDROID) | 360 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |