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

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

Issue 1761953002: Fix x86-64 Android build. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | runtime/vm/signal_handler_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/directory.h" 8 #include "bin/directory.h"
9 9
10 #include <dirent.h> // NOLINT 10 #include <dirent.h> // NOLINT
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // process umask. 366 // process umask.
367 int result = NO_RETRY_EXPECTED(mkdir(dir_name, 0777)); 367 int result = NO_RETRY_EXPECTED(mkdir(dir_name, 0777));
368 // If the directory already exists, treat it as a success. 368 // If the directory already exists, treat it as a success.
369 if (result == -1 && errno == EEXIST) { 369 if (result == -1 && errno == EEXIST) {
370 return (Exists(dir_name) == EXISTS); 370 return (Exists(dir_name) == EXISTS);
371 } 371 }
372 return (result == 0); 372 return (result == 0);
373 } 373 }
374 374
375 375
376 // Android doesn't currently provide mkdtemp. Once Android provied mkdtemp,
zra 2016/03/03 18:54:04 This comment appears to have been inaccurate. mkdt
377 // remove this function in favor of calling mkdtemp directly.
378 static char* MakeTempDirectory(char* path_template) {
379 if (mktemp(path_template) == NULL) {
380 return NULL;
381 }
382 if (mkdir(path_template, 0700) != 0) {
383 return NULL;
384 }
385 return path_template;
386 }
387
388
389 char* Directory::SystemTemp() { 376 char* Directory::SystemTemp() {
390 // Android does not have a /tmp directory. A partial substitute, 377 // Android does not have a /tmp directory. A partial substitute,
391 // suitable for bring-up work and tests, is to create a tmp 378 // suitable for bring-up work and tests, is to create a tmp
392 // directory in /data/local/tmp. 379 // directory in /data/local/tmp.
393 // 380 //
394 // TODO(4413): In the long run, when running in an application we should 381 // TODO(4413): In the long run, when running in an application we should
395 // probably use the appropriate directory from the Android API, 382 // probably use the appropriate directory from the Android API,
396 // probably what File.createTempFile uses. 383 // probably what File.createTempFile uses.
397 #define ANDROID_TEMP_DIR "/data/local/tmp" 384 #define ANDROID_TEMP_DIR "/data/local/tmp"
398 struct stat st; 385 struct stat st;
(...skipping 10 matching lines...) Expand all
409 // by the process umask. 396 // by the process umask.
410 // The return value must be freed by the caller. 397 // The return value must be freed by the caller.
411 PathBuffer path; 398 PathBuffer path;
412 path.Add(prefix); 399 path.Add(prefix);
413 if (!path.Add("XXXXXX")) { 400 if (!path.Add("XXXXXX")) {
414 // Pattern has overflowed. 401 // Pattern has overflowed.
415 return NULL; 402 return NULL;
416 } 403 }
417 char* result; 404 char* result;
418 do { 405 do {
419 result = MakeTempDirectory(path.AsString()); 406 result = mkdtemp(path.AsString());
420 } while (result == NULL && errno == EINTR); 407 } while (result == NULL && errno == EINTR);
421 if (result == NULL) { 408 if (result == NULL) {
422 return NULL; 409 return NULL;
423 } 410 }
424 return strdup(result); 411 return strdup(result);
425 } 412 }
426 413
427 414
428 bool Directory::Delete(const char* dir_name, bool recursive) { 415 bool Directory::Delete(const char* dir_name, bool recursive) {
429 if (!recursive) { 416 if (!recursive) {
(...skipping 15 matching lines...) Expand all
445 bool Directory::Rename(const char* path, const char* new_path) { 432 bool Directory::Rename(const char* path, const char* new_path) {
446 ExistsResult exists = Exists(path); 433 ExistsResult exists = Exists(path);
447 if (exists != EXISTS) return false; 434 if (exists != EXISTS) return false;
448 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); 435 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0);
449 } 436 }
450 437
451 } // namespace bin 438 } // namespace bin
452 } // namespace dart 439 } // namespace dart
453 440
454 #endif // defined(TARGET_OS_ANDROID) 441 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/signal_handler_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698