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

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

Issue 3001963002: [dart:io] Namespaces for file IO (Closed)
Patch Set: Fuchsia fix Created 3 years, 3 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 | « runtime/bin/platform_android.cc ('k') | runtime/bin/platform_linux.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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(HOST_OS_FUCHSIA) 6 #if defined(HOST_OS_FUCHSIA)
7 7
8 #include "bin/platform.h" 8 #include "bin/platform.h"
9 9
10 #include <magenta/process.h> 10 #include <magenta/process.h>
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 return NULL; 85 return NULL;
86 } 86 }
87 return name; 87 return name;
88 } 88 }
89 89
90 const char* Platform::ResolveExecutablePath() { 90 const char* Platform::ResolveExecutablePath() {
91 const char* executable_name = Platform::GetExecutableName(); 91 const char* executable_name = Platform::GetExecutableName();
92 if (executable_name == NULL) { 92 if (executable_name == NULL) {
93 return NULL; 93 return NULL;
94 } 94 }
95 if ((executable_name[0] == '/') && File::Exists(executable_name)) { 95 if ((executable_name[0] == '/') && File::Exists(NULL, executable_name)) {
96 return File::GetCanonicalPath(executable_name); 96 return File::GetCanonicalPath(NULL, executable_name);
97 } 97 }
98 if (strchr(executable_name, '/') != NULL) { 98 if (strchr(executable_name, '/') != NULL) {
99 const char* result = File::GetCanonicalPath(executable_name); 99 const char* result = File::GetCanonicalPath(NULL, executable_name);
100 if (File::Exists(result)) { 100 if (File::Exists(NULL, result)) {
101 return result; 101 return result;
102 } 102 }
103 } else { 103 } else {
104 const char* path = getenv("PATH"); 104 const char* path = getenv("PATH");
105 if (path == NULL) { 105 if (path == NULL) {
106 // If PATH isn't set, make some guesses about where we should look. 106 // If PATH isn't set, make some guesses about where we should look.
107 path = "/system/bin:/system/apps:/boot/bin"; 107 path = "/system/bin:/system/apps:/boot/bin";
108 } 108 }
109 char* pathcopy = DartUtils::ScopedCopyCString(path); 109 char* pathcopy = DartUtils::ScopedCopyCString(path);
110 char* result = DartUtils::ScopedCString(PATH_MAX + 1); 110 char* result = DartUtils::ScopedCString(PATH_MAX + 1);
111 char* save = NULL; 111 char* save = NULL;
112 while ((pathcopy = strtok_r(pathcopy, ":", &save)) != NULL) { 112 while ((pathcopy = strtok_r(pathcopy, ":", &save)) != NULL) {
113 snprintf(result, PATH_MAX, "%s/%s", pathcopy, executable_name); 113 snprintf(result, PATH_MAX, "%s/%s", pathcopy, executable_name);
114 result[PATH_MAX] = '\0'; 114 result[PATH_MAX] = '\0';
115 if (File::Exists(result)) { 115 if (File::Exists(NULL, result)) {
116 return File::GetCanonicalPath(result); 116 return File::GetCanonicalPath(NULL, result);
117 } 117 }
118 pathcopy = NULL; 118 pathcopy = NULL;
119 } 119 }
120 } 120 }
121 // Couldn't find it. This causes null to be returned for 121 // Couldn't find it. This causes null to be returned for
122 // Platform.resovledExecutable. 122 // Platform.resovledExecutable.
123 return NULL; 123 return NULL;
124 } 124 }
125 125
126 void Platform::Exit(int exit_code) { 126 void Platform::Exit(int exit_code) {
127 exit(exit_code); 127 exit(exit_code);
128 } 128 }
129 129
130 } // namespace bin 130 } // namespace bin
131 } // namespace dart 131 } // namespace dart
132 132
133 #endif // defined(HOST_OS_FUCHSIA) 133 #endif // defined(HOST_OS_FUCHSIA)
OLDNEW
« no previous file with comments | « runtime/bin/platform_android.cc ('k') | runtime/bin/platform_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698