atom_command_line.cc 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2013 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include "atom/common/atom_command_line.h"
  5. #include "base/command_line.h"
  6. #include "node/deps/uv/include/uv.h"
  7. namespace atom {
  8. // static
  9. std::vector<std::string> AtomCommandLine::argv_;
  10. #if defined(OS_WIN)
  11. // static
  12. std::vector<std::wstring> AtomCommandLine::wargv_;
  13. #endif
  14. // static
  15. void AtomCommandLine::Init(int argc, const char* const* argv) {
  16. // Hack around with the argv pointer. Used for process.title = "blah"
  17. char** new_argv = uv_setup_args(argc, const_cast<char**>(argv));
  18. for (int i = 0; i < argc; ++i) {
  19. argv_.push_back(new_argv[i]);
  20. }
  21. }
  22. #if defined(OS_WIN)
  23. // static
  24. void AtomCommandLine::InitW(int argc, const wchar_t* const* argv) {
  25. for (int i = 0; i < argc; ++i) {
  26. wargv_.push_back(argv[i]);
  27. }
  28. }
  29. #endif
  30. #if defined(OS_LINUX)
  31. // static
  32. void AtomCommandLine::InitializeFromCommandLine() {
  33. argv_ = base::CommandLine::ForCurrentProcess()->argv();
  34. }
  35. #endif
  36. } // namespace atom