OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 InitFromArgv(new_argv); | 213 InitFromArgv(new_argv); |
214 } | 214 } |
215 | 215 |
216 void CommandLine::InitFromArgv(const StringVector& argv) { | 216 void CommandLine::InitFromArgv(const StringVector& argv) { |
217 argv_ = StringVector(1); | 217 argv_ = StringVector(1); |
218 begin_args_ = 1; | 218 begin_args_ = 1; |
219 SetProgram(argv.empty() ? FilePath() : FilePath(argv[0])); | 219 SetProgram(argv.empty() ? FilePath() : FilePath(argv[0])); |
220 AppendSwitchesAndArguments(*this, argv); | 220 AppendSwitchesAndArguments(*this, argv); |
221 } | 221 } |
222 | 222 |
223 CommandLine::StringType CommandLine::command_line_string() const { | 223 CommandLine::StringType CommandLine::GetCommandLineString() const { |
224 StringType string(argv_[0]); | 224 StringType string(argv_[0]); |
225 #if defined(OS_WIN) | 225 #if defined(OS_WIN) |
226 string = QuoteForCommandLineToArgvW(string); | 226 string = QuoteForCommandLineToArgvW(string); |
227 #endif | 227 #endif |
228 // Append switches and arguments. | 228 // Append switches and arguments. |
229 bool parse_switches = true; | 229 bool parse_switches = true; |
230 for (size_t i = 1; i < argv_.size(); ++i) { | 230 for (size_t i = 1; i < argv_.size(); ++i) { |
231 CommandLine::StringType arg = argv_[i]; | 231 CommandLine::StringType arg = argv_[i]; |
232 CommandLine::StringType switch_string; | 232 CommandLine::StringType switch_string; |
233 CommandLine::StringType switch_value; | 233 CommandLine::StringType switch_value; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 int num_args = 0; | 393 int num_args = 0; |
394 wchar_t** args = NULL; | 394 wchar_t** args = NULL; |
395 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); | 395 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); |
396 | 396 |
397 PLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " << | 397 PLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " << |
398 command_line; | 398 command_line; |
399 InitFromArgv(num_args, args); | 399 InitFromArgv(num_args, args); |
400 LocalFree(args); | 400 LocalFree(args); |
401 } | 401 } |
402 #endif | 402 #endif |
OLD | NEW |