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

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

Issue 15894004: dart:io | Fix a few bugs in the Android port of dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/directory_android.cc ('k') | runtime/bin/socket_android.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_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
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
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)
OLDNEW
« no previous file with comments | « runtime/bin/directory_android.cc ('k') | runtime/bin/socket_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698