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

Unified Diff: runtime/bin/platform.h

Issue 1145053002: Make Platform.executable return a fully qualified path the the executable (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix comment Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/bin/platform.cc » ('j') | runtime/bin/platform_macos.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/platform.h
diff --git a/runtime/bin/platform.h b/runtime/bin/platform.h
index 78cb33de62be8a4af4251feb7ee5d500e14f608f..6b81539da10433bb69f943b98eb2756d019479ba 100644
--- a/runtime/bin/platform.h
+++ b/runtime/bin/platform.h
@@ -39,11 +39,21 @@ class Platform {
static char** Environment(intptr_t* count);
static void FreeEnvironment(char** env, intptr_t count);
- // Stores and gets the executable name.
+ static char* ResolveExecutablePath();
+
+ // Stores the executable name.
static void SetExecutableName(const char* executable_name) {
executable_name_ = executable_name;
Lasse Reichstein Nielsen 2015/05/20 10:48:43 Should this set ..._resolved_ to true?
Søren Gjesse 2015/05/20 11:14:24 This is being called from main() with the value of
}
static const char* GetExecutableName() {
+ if (!executable_name_resolved_) {
+ // Try to resolve the executable path using platform specific APIs.
+ char* path = Platform::ResolveExecutablePath();
+ if (path != NULL) {
+ executable_name_ = path;
+ }
+ executable_name_resolved_ = true;
+ }
return executable_name_;
}
@@ -68,7 +78,11 @@ class Platform {
}
private:
+ // The path to the executable.
static const char* executable_name_;
+ // State to indicate whether the executable name has been resolved.
+ static bool executable_name_resolved_;
Lasse Reichstein Nielsen 2015/05/20 10:48:43 Is this really necessary? As opposed to just check
Søren Gjesse 2015/05/20 11:14:24 See above. We have a fallback to argv[0].
+
static const char* package_root_;
static int script_index_;
static char** argv_; // VM flags are argv_[1 ... script_index_ - 1]
« no previous file with comments | « no previous file | runtime/bin/platform.cc » ('j') | runtime/bin/platform_macos.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698