Chromium Code Reviews| 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] |