diff options
-rw-r--r-- | base/command_line.cc | 12 | ||||
-rw-r--r-- | base/command_line.h | 2 | ||||
-rw-r--r-- | base/command_line_unittest.cc | 3 |
3 files changed, 9 insertions, 8 deletions
diff --git a/base/command_line.cc b/base/command_line.cc index 4d76ed0..477b4e7 100644 --- a/base/command_line.cc +++ b/base/command_line.cc @@ -332,18 +332,18 @@ CommandLine::StringType CommandLine::GetSwitchValueNative( } FilePath CommandLine::GetProgram() const { - return FilePath::FromWStringHack(program()); +#if defined(OS_WIN) + return FilePath(program_); +#else + DCHECK_GT(argv_.size(), 0U); + return FilePath(argv_[0]); +#endif } #if defined(OS_WIN) std::wstring CommandLine::program() const { return program_; } -#else -std::wstring CommandLine::program() const { - DCHECK_GT(argv_.size(), 0U); - return base::SysNativeMBToWide(argv_[0]); -} #endif #if defined(OS_POSIX) diff --git a/base/command_line.h b/base/command_line.h index 9cad0f1..31c0f5f 100644 --- a/base/command_line.h +++ b/base/command_line.h @@ -162,9 +162,9 @@ class CommandLine { // APIs that work with wstrings are deprecated. // TODO(evanm): remove all of these. - std::wstring program() const; #if defined(OS_WIN) // Deprecated on non-Windows. + std::wstring program() const; bool HasSwitch(const std::wstring& switch_string) const; #endif diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc index a34cf43..cd26fc5 100644 --- a/base/command_line_unittest.cc +++ b/base/command_line_unittest.cc @@ -50,7 +50,8 @@ TEST(CommandLineTest, CommandLineConstructor) { EXPECT_FALSE(cl.HasSwitch("not-a-switch")); EXPECT_FALSE(cl.HasSwitch("--")); - EXPECT_EQ(L"program", cl.program()); + EXPECT_EQ(FilePath(FILE_PATH_LITERAL("program")).value(), + cl.GetProgram().value()); EXPECT_TRUE(cl.HasSwitch("foo")); EXPECT_TRUE(cl.HasSwitch("bar")); |