diff options
author | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-23 15:38:29 +0000 |
---|---|---|
committer | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-23 15:38:29 +0000 |
commit | 7de8b1873902cb8857a27ae6b0b6d5b5291d62b0 (patch) | |
tree | 78c19a6307e0bee6eb8a2cda8fc99b6bcc373072 /remoting/host | |
parent | e5366896e9ccb3dd17c590d115bd999e987a33af (diff) | |
download | chromium_src-7de8b1873902cb8857a27ae6b0b6d5b5291d62b0.zip chromium_src-7de8b1873902cb8857a27ae6b0b6d5b5291d62b0.tar.gz chromium_src-7de8b1873902cb8857a27ae6b0b6d5b5291d62b0.tar.bz2 |
Get scripts working independent of where they are run.
Also store script data in home directory.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/2832019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50598 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r-- | remoting/host/simple_host_process.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc index 5ed70e0..09f6a96 100644 --- a/remoting/host/simple_host_process.cc +++ b/remoting/host/simple_host_process.cc @@ -14,6 +14,7 @@ #include <iostream> #include <string> +#include <stdlib.h> #include "build/build_config.h" @@ -21,6 +22,7 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/logging.h" +#include "base/scoped_nsautorelease_pool.h" #include "base/thread.h" #include "base/waitable_event.h" #include "remoting/host/capturer_fake.h" @@ -40,15 +42,22 @@ #endif #if defined(OS_WIN) -const std::wstring kDefaultConfigPath = L"ChromotingConfig.json"; +const std::wstring kDefaultConfigPath = L".ChromotingConfig.json"; +const wchar_t kHomePath[] = L"HOMEPATH"; +const wchar_t* GetEnvironmentVar(const wchar_t* x) { return _wgetenv(x); } #else -const std::string kDefaultConfigPath = "ChromotingConfig.json"; +static char* GetEnvironmentVar(const char* x) { return getenv(x); } +const char kHomePath[] = "HOME"; +const std::string kDefaultConfigPath = ".ChromotingConfig.json"; #endif const std::string kFakeSwitchName = "fake"; const std::string kConfigSwitchName = "config"; int main(int argc, char** argv) { + // Needed for the Mac, so we don't leak objects when threads are created. + base::ScopedNSAutoreleasePool pool; + CommandLine::Init(argc, argv); const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); @@ -72,7 +81,8 @@ int main(int argc, char** argv) { // Check the argument to see if we should use a fake capturer and encoder. bool fake = cmd_line->HasSwitch(kFakeSwitchName); - FilePath config_path(kDefaultConfigPath); + FilePath config_path(GetEnvironmentVar(kHomePath)); + config_path = config_path.Append(kDefaultConfigPath); if (cmd_line->HasSwitch(kConfigSwitchName)) { config_path = cmd_line->GetSwitchValuePath(kConfigSwitchName); } |