summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/command_line.cc19
-rw-r--r--base/command_line.h12
-rw-r--r--base/command_line_unittest.cc20
-rw-r--r--chrome/browser/browser_init.cc23
-rw-r--r--courgette/courgette_tool.cc10
-rw-r--r--media/test/ffmpeg_tests/ffmpeg_tests.cc52
-rw-r--r--media/tools/media_bench/media_bench.cc50
-rw-r--r--media/tools/player_wtl/player_wtl.cc2
-rw-r--r--media/tools/scaler_bench/scaler_bench.cc2
-rw-r--r--media/tools/wav_ola_test/wav_ola_test.cc13
-rw-r--r--net/tools/hresolv/hresolv.cc14
-rw-r--r--o3d/converter/cross/converter_main.cc8
-rw-r--r--o3d/converter/cross/verifier_main.cc8
-rw-r--r--o3d/converter_edge/cross/converter_main.cc8
-rw-r--r--o3d/converter_edge/cross/verifier_main.cc8
-rw-r--r--tools/imagediff/image_diff.cc18
-rw-r--r--webkit/tools/test_shell/test_shell_main.cc12
17 files changed, 145 insertions, 134 deletions
diff --git a/base/command_line.cc b/base/command_line.cc
index 2a7824d..c046125 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -82,7 +82,7 @@ void CommandLine::ParseFromString(const std::wstring& command_line) {
TrimWhitespace(args[i], TRIM_ALL, &arg);
if (!parse_switches) {
- loose_values_.push_back(arg);
+ args_.push_back(arg);
continue;
}
@@ -96,7 +96,7 @@ void CommandLine::ParseFromString(const std::wstring& command_line) {
if (IsSwitch(arg, &switch_string, &switch_value)) {
switches_[switch_string] = switch_value;
} else {
- loose_values_.push_back(arg);
+ args_.push_back(arg);
}
}
@@ -130,7 +130,7 @@ void CommandLine::InitFromArgv(const std::vector<std::string>& argv) {
const std::string& arg = argv_[i];
if (!parse_switches) {
- loose_values_.push_back(arg);
+ args_.push_back(arg);
continue;
}
@@ -144,7 +144,7 @@ void CommandLine::InitFromArgv(const std::vector<std::string>& argv) {
if (IsSwitch(arg, &switch_string, &switch_value)) {
switches_[switch_string] = switch_value;
} else {
- loose_values_.push_back(arg);
+ args_.push_back(arg);
}
}
}
@@ -287,19 +287,10 @@ std::wstring CommandLine::GetSwitchValue(
}
#if defined(OS_WIN)
-std::vector<std::wstring> CommandLine::GetLooseValues() const {
- return loose_values_;
-}
std::wstring CommandLine::program() const {
return program_;
}
#else
-std::vector<std::wstring> CommandLine::GetLooseValues() const {
- std::vector<std::wstring> values;
- for (size_t i = 0; i < loose_values_.size(); ++i)
- values.push_back(base::SysNativeMBToWide(loose_values_[i]));
- return values;
-}
std::wstring CommandLine::program() const {
DCHECK_GT(argv_.size(), 0U);
return base::SysNativeMBToWide(argv_[0]);
@@ -375,7 +366,7 @@ void CommandLine::AppendLooseValue(const std::wstring& value) {
// TODO(evan): quoting?
command_line_string_.append(L" ");
command_line_string_.append(value);
- loose_values_.push_back(value);
+ args_.push_back(value);
}
void CommandLine::AppendArguments(const CommandLine& other,
diff --git a/base/command_line.h b/base/command_line.h
index c68711a..2c4f32d 100644
--- a/base/command_line.h
+++ b/base/command_line.h
@@ -5,10 +5,9 @@
// This class works with command lines: building and parsing.
// Switches can optionally have a value attached using an equals sign,
// as in "-switch=value". Arguments that aren't prefixed with a
-// switch prefix are considered "loose parameters". Switch names are
-// case-insensitive. An argument of "--" will terminate switch
-// parsing, causing everything after to be considered as loose
-// parameters.
+// switch prefix are saved as extra arguments. An argument of "--"
+// will terminate switch parsing, causing everything after to be
+// considered as extra arguments.
// There is a singleton read-only CommandLine that represents the command
// line that the current process was started with. It must be initialized
@@ -139,8 +138,7 @@ class CommandLine {
}
// Get the remaining arguments to the command.
- // WARNING: this is incorrect on POSIX; we must do string conversions.
- std::vector<std::wstring> GetLooseValues() const;
+ const std::vector<StringType>& args() const { return args_; }
#if defined(OS_WIN)
// Returns the original command line string.
@@ -239,7 +237,7 @@ class CommandLine {
SwitchMap switches_;
// Non-switch command-line arguments.
- std::vector<StringType> loose_values_;
+ std::vector<StringType> args_;
// We allow copy constructors, because a common pattern is to grab a
// copy of the current process's command line and then add some
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc
index 6544c13..8f3c7c0 100644
--- a/base/command_line_unittest.cc
+++ b/base/command_line_unittest.cc
@@ -59,21 +59,21 @@ TEST(CommandLineTest, CommandLineConstructor) {
"other-switches"));
EXPECT_EQ("45--output-rotation", cl.GetSwitchValueASCII("input-translation"));
- std::vector<std::wstring> loose_values = cl.GetLooseValues();
- ASSERT_EQ(5U, loose_values.size());
+ const std::vector<CommandLine::StringType>& args = cl.args();
+ ASSERT_EQ(5U, args.size());
- std::vector<std::wstring>::const_iterator iter = loose_values.begin();
- EXPECT_EQ(L"flim", *iter);
+ std::vector<CommandLine::StringType>::const_iterator iter = args.begin();
+ EXPECT_EQ(FILE_PATH_LITERAL("flim"), *iter);
++iter;
- EXPECT_EQ(L"flan", *iter);
+ EXPECT_EQ(FILE_PATH_LITERAL("flan"), *iter);
++iter;
- EXPECT_EQ(L"--", *iter);
+ EXPECT_EQ(FILE_PATH_LITERAL("--"), *iter);
++iter;
- EXPECT_EQ(L"--not-a-switch", *iter);
+ EXPECT_EQ(FILE_PATH_LITERAL("--not-a-switch"), *iter);
++iter;
- EXPECT_EQ(L"in the time of submarines...", *iter);
+ EXPECT_EQ(FILE_PATH_LITERAL("in the time of submarines..."), *iter);
++iter;
- EXPECT_TRUE(iter == loose_values.end());
+ EXPECT_TRUE(iter == args.end());
#if defined(OS_POSIX)
const std::vector<std::string>& argvec = cl.argv();
@@ -93,7 +93,7 @@ TEST(CommandLineTest, EmptyString) {
CommandLine cl(0, NULL);
EXPECT_TRUE(cl.argv().size() == 0);
#endif
- EXPECT_EQ(0U, cl.GetLooseValues().size());
+ EXPECT_EQ(0U, cl.args().size());
}
// Test methods for appending switches to a command line.
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 1832960..e5b15e2 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -839,27 +839,29 @@ void BrowserInit::LaunchWithProfile::AddBadFlagsInfoBarIfNecessary(
std::vector<GURL> BrowserInit::LaunchWithProfile::GetURLsFromCommandLine(
Profile* profile) {
std::vector<GURL> urls;
- std::vector<std::wstring> params = command_line_.GetLooseValues();
+ FilePath cur_dir = FilePath::FromWStringHack(cur_dir_);
+ const std::vector<CommandLine::StringType>& params = command_line_.args();
for (size_t i = 0; i < params.size(); ++i) {
- std::wstring& value = params[i];
+ FilePath param = FilePath(params[i]);
// Handle Vista way of searching - "? <search-term>"
- if (value.find(L"? ") == 0) {
+ if (param.value().find(FILE_PATH_LITERAL("? ")) == 0) {
const TemplateURL* default_provider =
profile->GetTemplateURLModel()->GetDefaultSearchProvider();
if (!default_provider || !default_provider->url()) {
// No search provider available. Just treat this as regular URL.
- urls.push_back(URLFixerUpper::FixupRelativeFile(cur_dir_, value));
+ urls.push_back(URLFixerUpper::FixupRelativeFile(cur_dir, param));
continue;
}
const TemplateURLRef* search_url = default_provider->url();
DCHECK(search_url->SupportsReplacement());
+ std::wstring search_term = param.ToWStringHack().substr(2);
urls.push_back(GURL(search_url->ReplaceSearchTerms(
- *default_provider, value.substr(2),
+ *default_provider, search_term,
TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())));
} else {
// This will create a file URL or a regular URL.
- GURL url(URLFixerUpper::FixupRelativeFile(cur_dir_, value));
+ GURL url(URLFixerUpper::FixupRelativeFile(cur_dir, param));
// Exclude dangerous schemes.
if (url.is_valid()) {
ChildProcessSecurityPolicy *policy =
@@ -944,7 +946,7 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
switches::kTestingChannelID);
// TODO(sanjeevr) Check if we need to make this a singleton for
// compatibility with the old testing code
- // If there are any loose parameters, we expect each one to generate a
+ // If there are any extra parameters, we expect each one to generate a
// new tab; if there are none then we get one homepage tab.
int expected_tab_count = 1;
if (command_line.HasSwitch(switches::kRestoreLastSession)) {
@@ -953,7 +955,7 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
StringToInt(restore_session_value, &expected_tab_count);
} else {
expected_tab_count =
- std::max(1, static_cast<int>(command_line.GetLooseValues().size()));
+ std::max(1, static_cast<int>(command_line.args().size()));
}
CreateAutomationProvider<TestingAutomationProvider>(
testing_channel_id,
@@ -1018,11 +1020,10 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
if (command_line.HasSwitch(switches::kAutomationClientChannelID)) {
std::string automation_channel_id = command_line.GetSwitchValueASCII(
switches::kAutomationClientChannelID);
- // If there are any loose parameters, we expect each one to generate a
+ // If there are any extra parameters, we expect each one to generate a
// new tab; if there are none then we have no tabs
size_t expected_tabs =
- std::max(static_cast<int>(command_line.GetLooseValues().size()),
- 0);
+ std::max(static_cast<int>(command_line.args().size()), 0);
if (expected_tabs == 0)
silent_launch = true;
diff --git a/courgette/courgette_tool.cc b/courgette/courgette_tool.cc
index f118bd9..ef9fa71 100644
--- a/courgette/courgette_tool.cc
+++ b/courgette/courgette_tool.cc
@@ -359,7 +359,15 @@ int main(int argc, const char* argv[]) {
bool cmd_spread_1_adjusted = command_line.HasSwitch("gen1a");
bool cmd_spread_1_unadjusted = command_line.HasSwitch("gen1u");
- std::vector<std::wstring> values = command_line.GetLooseValues();
+ // TODO(evanm): this whole file should use FilePaths instead of wstrings.
+ std::vector<std::wstring> values;
+ for (size_t i = 0; i < command_line.args().size(); ++i) {
+#if defined(OS_WIN)
+ values.push_back(command_line.args()[i]);
+#else
+ values.push_back(ASCIIToWide(command_line.args()[i]));
+#endif
+ }
// '-repeat=N' is for debugging. Running many iterations can reveal leaks and
// bugs in cleanup.
diff --git a/media/test/ffmpeg_tests/ffmpeg_tests.cc b/media/test/ffmpeg_tests/ffmpeg_tests.cc
index 47dd1b1..a967bc3 100644
--- a/media/test/ffmpeg_tests/ffmpeg_tests.cc
+++ b/media/test/ffmpeg_tests/ffmpeg_tests.cc
@@ -70,10 +70,7 @@ int main(int argc, const char** argv) {
CommandLine::Init(argc, argv);
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
- // TODO(evanm): GetLooseValues() should return a
- // CommandLine::StringType, which can be converted to FilePaths
- // directly.
- std::vector<std::wstring> filenames(cmd_line->GetLooseValues());
+ const std::vector<CommandLine::StringType>& filenames = cmd_line->args();
if (filenames.empty()) {
std::cerr << "Usage: " << argv[0] << " MEDIAFILE" << std::endl;
@@ -89,12 +86,10 @@ int main(int argc, const char** argv) {
}
// Retrieve command line options.
- std::string in_path(WideToASCII(filenames[0]));
+ FilePath in_path(filenames[0]);
FilePath out_path;
- if (filenames.size() > 1) {
- // See TODO above the declaration of filenames.
- out_path = FilePath::FromWStringHack(filenames[1]);
- }
+ if (filenames.size() > 1)
+ out_path = FilePath(filenames[1]);
// Default flags that match Chrome defaults.
int video_threads = 3;
@@ -122,17 +117,25 @@ int main(int argc, const char** argv) {
av_register_all();
av_register_protocol(&kFFmpegFileProtocol);
AVFormatContext* format_context = NULL;
- int result = av_open_input_file(&format_context, in_path.c_str(),
+ // av_open_input_file wants a char*, which can't work with wide paths.
+ // So we assume ASCII on Windows. On other platforms we can pass the
+ // path bytes through verbatim.
+#if defined(OS_WIN)
+ std::string string_path = WideToASCII(in_path.value());
+#else
+ const std::string& string_path = in_path.value();
+#endif
+ int result = av_open_input_file(&format_context, string_path.c_str(),
NULL, 0, NULL);
if (result < 0) {
switch (result) {
case AVERROR_NOFMT:
std::cerr << "Error: File format not supported "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
break;
default:
std::cerr << "Error: Could not open input for "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
break;
}
return 1;
@@ -152,7 +155,7 @@ int main(int argc, const char** argv) {
// Parse a little bit of the stream to fill out the format context.
if (av_find_stream_info(format_context) < 0) {
std::cerr << "Error: Could not find stream info for "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
return 1;
}
@@ -201,7 +204,7 @@ int main(int argc, const char** argv) {
// Only continue if we found our target stream.
if (target_stream < 0) {
std::cerr << "Error: Could not find target stream "
- << target_stream << " for " << in_path << std::endl;
+ << target_stream << " for " << in_path.value() << std::endl;
return 1;
}
@@ -213,14 +216,14 @@ int main(int argc, const char** argv) {
// Only continue if we found our codec.
if (!codec) {
std::cerr << "Error: Could not find codec for "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
return 1;
}
// TODO(fbarchard): On next ffmpeg roll, retest if this work around is needed.
if (codec_context->codec_id == CODEC_ID_THEORA) {
std::cerr << "Warning: Disabling threads to avoid Theora bug "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
video_threads = 1;
}
@@ -240,7 +243,7 @@ int main(int argc, const char** argv) {
if (avcodec_open(codec_context, codec) < 0) {
std::cerr << "Error: Could not open codec "
<< codec_context->codec->name << " for "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
return 1;
}
@@ -253,7 +256,7 @@ int main(int argc, const char** argv) {
avcodec_alloc_frame());
if (!frame.get()) {
std::cerr << "Error: avcodec_alloc_frame for "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
return 1;
}
@@ -305,7 +308,8 @@ int main(int argc, const char** argv) {
if (fwrite(samples.get(), 1, size_out, output) !=
static_cast<size_t>(size_out)) {
std::cerr << "Error: Could not write "
- << size_out << " bytes for " << in_path << std::endl;
+ << size_out << " bytes for " << in_path.value()
+ << std::endl;
return 1;
}
}
@@ -363,7 +367,7 @@ int main(int argc, const char** argv) {
bytes_per_line) {
std::cerr << "Error: Could not write data after "
<< copy_lines << " lines for "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
return 1;
}
source += source_stride;
@@ -391,7 +395,7 @@ int main(int argc, const char** argv) {
// Make sure our decoding went OK.
if (result < 0) {
std::cerr << "Error: avcodec_decode returned "
- << result << " for " << in_path << std::endl;
+ << result << " for " << in_path.value() << std::endl;
return 1;
}
}
@@ -476,19 +480,19 @@ int main(int argc, const char** argv) {
}
if (hash_djb2) {
*log_out << " DJB2 Hash:" << std::setw(11) << hash_value
- << " " << in_path << std::endl;
+ << " " << in_path.value() << std::endl;
}
if (hash_md5) {
MD5Digest digest; // The result of the computation.
MD5Final(&digest, &ctx);
*log_out << " MD5 Hash: " << MD5DigestToBase16(digest)
- << " " << in_path << std::endl;
+ << " " << in_path.value() << std::endl;
}
#endif // SHOW_VERBOSE
#if defined(ENABLE_WINDOWS_EXCEPTIONS)
} __except(EXCEPTION_EXECUTE_HANDLER) {
*log_out << " Exception:" << std::setw(11) << GetExceptionCode()
- << " " << in_path << std::endl;
+ << " " << in_path.value() << std::endl;
return 1;
}
#endif
diff --git a/media/tools/media_bench/media_bench.cc b/media/tools/media_bench/media_bench.cc
index ad6a7c2..cdc2560 100644
--- a/media/tools/media_bench/media_bench.cc
+++ b/media/tools/media_bench/media_bench.cc
@@ -89,10 +89,7 @@ int main(int argc, const char** argv) {
CommandLine::Init(argc, argv);
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
- // TODO(evanm): GetLooseValues() should return a
- // CommandLine::StringType, which can be converted to FilePaths
- // directly.
- std::vector<std::wstring> filenames(cmd_line->GetLooseValues());
+ const std::vector<CommandLine::StringType>& filenames = cmd_line->args();
if (filenames.empty()) {
std::cerr << "Usage: " << argv[0] << " [OPTIONS] FILE [DUMPFILE]\n"
<< " --stream=[audio|video] "
@@ -129,12 +126,10 @@ int main(int argc, const char** argv) {
}
// Retrieve command line options.
- std::string in_path(WideToASCII(filenames[0]));
+ FilePath in_path(filenames[0]);
FilePath out_path;
- if (filenames.size() > 1) {
- // See TODO above the declaration of filenames.
- out_path = FilePath::FromWStringHack(filenames[1]);
- }
+ if (filenames.size() > 1)
+ out_path = FilePath(filenames[1]);
CodecType target_codec = CODEC_TYPE_UNKNOWN;
// Determine whether to benchmark audio or video decoding.
@@ -230,17 +225,25 @@ int main(int argc, const char** argv) {
av_register_all();
av_register_protocol(&kFFmpegFileProtocol);
AVFormatContext* format_context = NULL;
- int result = av_open_input_file(&format_context, in_path.c_str(),
+ // av_open_input_file wants a char*, which can't work with wide paths.
+ // So we assume ASCII on Windows. On other platforms we can pass the
+ // path bytes through verbatim.
+#if defined(OS_WIN)
+ std::string string_path = WideToASCII(in_path.value());
+#else
+ const std::string& string_path = in_path.value();
+#endif
+ int result = av_open_input_file(&format_context, string_path.c_str(),
NULL, 0, NULL);
if (result < 0) {
switch (result) {
case AVERROR_NOFMT:
std::cerr << "Error: File format not supported "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
break;
default:
std::cerr << "Error: Could not open input for "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
break;
}
return 1;
@@ -270,7 +273,7 @@ int main(int argc, const char** argv) {
// Parse a little bit of the stream to fill out the format context.
if (av_find_stream_info(format_context) < 0) {
std::cerr << "Error: Could not find stream info for "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
return 1;
}
@@ -300,7 +303,7 @@ int main(int argc, const char** argv) {
// Only continue if we found our target stream.
if (target_stream < 0) {
std::cerr << "Error: Could not find target stream "
- << target_stream << " for " << in_path << std::endl;
+ << target_stream << " for " << in_path.value() << std::endl;
return 1;
}
@@ -312,7 +315,7 @@ int main(int argc, const char** argv) {
// Only continue if we found our codec.
if (!codec) {
std::cerr << "Error: Could not find codec for "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
return 1;
}
@@ -344,7 +347,7 @@ int main(int argc, const char** argv) {
if (avcodec_open(codec_context, codec) < 0) {
std::cerr << "Error: Could not open codec "
<< codec_context->codec->name << " for "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
return 1;
}
@@ -357,7 +360,7 @@ int main(int argc, const char** argv) {
avcodec_alloc_frame());
if (!frame.get()) {
std::cerr << "Error: avcodec_alloc_frame for "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
return 1;
}
@@ -409,7 +412,8 @@ int main(int argc, const char** argv) {
if (fwrite(samples.get(), 1, size_out, output) !=
static_cast<size_t>(size_out)) {
std::cerr << "Error: Could not write "
- << size_out << " bytes for " << in_path << std::endl;
+ << size_out << " bytes for " << in_path.value()
+ << std::endl;
return 1;
}
}
@@ -467,7 +471,7 @@ int main(int argc, const char** argv) {
bytes_per_line) {
std::cerr << "Error: Could not write data after "
<< copy_lines << " lines for "
- << in_path << std::endl;
+ << in_path.value() << std::endl;
return 1;
}
source += source_stride;
@@ -495,7 +499,7 @@ int main(int argc, const char** argv) {
// Make sure our decoding went OK.
if (result < 0) {
std::cerr << "Error: avcodec_decode returned "
- << result << " for " << in_path << std::endl;
+ << result << " for " << in_path.value() << std::endl;
return 1;
}
}
@@ -556,18 +560,18 @@ int main(int argc, const char** argv) {
}
if (hash_djb2) {
*log_out << " DJB2 Hash:" << std::setw(11) << hash_value
- << " " << in_path << std::endl;
+ << " " << in_path.value() << std::endl;
}
if (hash_md5) {
MD5Digest digest; // The result of the computation.
MD5Final(&digest, &ctx);
*log_out << " MD5 Hash: " << MD5DigestToBase16(digest)
- << " " << in_path << std::endl;
+ << " " << in_path.value() << std::endl;
}
#if defined(ENABLE_WINDOWS_EXCEPTIONS)
} __except(EXCEPTION_EXECUTE_HANDLER) {
*log_out << " Exception:" << std::setw(11) << GetExceptionCode()
- << " " << in_path << std::endl;
+ << " " << in_path.value() << std::endl;
return 1;
}
#endif
diff --git a/media/tools/player_wtl/player_wtl.cc b/media/tools/player_wtl/player_wtl.cc
index 5df87a7..3bb8f9e 100644
--- a/media/tools/player_wtl/player_wtl.cc
+++ b/media/tools/player_wtl/player_wtl.cc
@@ -31,7 +31,7 @@ int Run(wchar_t* win_cmd_line, int cmd_show) {
CommandLine::Init(0, NULL);
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
- std::vector<std::wstring> filenames(cmd_line->GetLooseValues());
+ const std::vector<std::wstring>& filenames = cmd_line->args();
CMessageLoop the_loop;
g_module.AddMessageLoop(&the_loop);
diff --git a/media/tools/scaler_bench/scaler_bench.cc b/media/tools/scaler_bench/scaler_bench.cc
index 749e1a6..b5d2ae1 100644
--- a/media/tools/scaler_bench/scaler_bench.cc
+++ b/media/tools/scaler_bench/scaler_bench.cc
@@ -135,7 +135,7 @@ int main(int argc, const char** argv) {
CommandLine::Init(argc, argv);
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
- if (!cmd_line->GetLooseValues().empty()) {
+ if (!cmd_line->args().empty()) {
std::cerr << "Usage: " << argv[0] << " [OPTIONS]\n"
<< " --frames=N "
<< "Number of frames\n"
diff --git a/media/tools/wav_ola_test/wav_ola_test.cc b/media/tools/wav_ola_test/wav_ola_test.cc
index 0aec9fd..4c006c3 100644
--- a/media/tools/wav_ola_test/wav_ola_test.cc
+++ b/media/tools/wav_ola_test/wav_ola_test.cc
@@ -71,7 +71,7 @@ int main(int argc, const char** argv) {
CommandLine::Init(argc, argv);
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
- std::vector<std::wstring> filenames(cmd_line->GetLooseValues());
+ const std::vector<CommandLine::StringType>& filenames = cmd_line->args();
if (filenames.empty()) {
std::cerr << "Usage: " << argv[0] << " RATE INFILE OUTFILE\n"
<< std::endl;
@@ -79,12 +79,17 @@ int main(int argc, const char** argv) {
}
// Retrieve command line options.
- FilePath in_path(FilePath::FromWStringHack(filenames[1]));
- FilePath out_path(FilePath::FromWStringHack(filenames[2]));
+ FilePath in_path(filenames[1]);
+ FilePath out_path(filenames[2]);
double playback_rate = 0.0;
// Determine speed of rerecord.
- if (!StringToDouble(WideToUTF8(filenames[0]), &playback_rate))
+#if defined(OS_WIN)
+ std::string filename_str = WideToASCII(filenames[0]);
+#else
+ const std::string& filename_str = filenames[0];
+#endif
+ if (!StringToDouble(filename_str, &playback_rate))
playback_rate = 0.0;
// Open input file.
diff --git a/net/tools/hresolv/hresolv.cc b/net/tools/hresolv/hresolv.cc
index 9c67070..d524bd7 100644
--- a/net/tools/hresolv/hresolv.cc
+++ b/net/tools/hresolv/hresolv.cc
@@ -354,14 +354,18 @@ bool ParseCommandLine(CommandLine* command_line, CommandLineOptions* options) {
}
bool ReadHostsAndTimesFromLooseValues(
- const std::vector<std::wstring>& loose_args,
+ const std::vector<CommandLine::StringType>& args,
std::vector<HostAndTime>* hosts_and_times) {
- std::vector<std::wstring>::const_iterator loose_args_end = loose_args.end();
- for (std::vector<std::wstring>::const_iterator it = loose_args.begin();
- it != loose_args_end;
+ for (std::vector<CommandLine::StringType>::const_iterator it =
+ args.begin();
+ it != args.end();
++it) {
// TODO(cbentzel): Read time offset.
+#if defined(OS_WIN)
HostAndTime host_and_time = {WideToASCII(*it), 0};
+#else
+ HostAndTime host_and_time = {*it, 0};
+#endif
hosts_and_times->push_back(host_and_time);
}
return true;
@@ -431,7 +435,7 @@ int main(int argc, char** argv) {
// file into memory.
std::vector<HostAndTime> hosts_and_times;
if (options.input_path.empty()) {
- if (!ReadHostsAndTimesFromLooseValues(command_line->GetLooseValues(),
+ if (!ReadHostsAndTimesFromLooseValues(command_line->args(),
&hosts_and_times)) {
exit(1);
}
diff --git a/o3d/converter/cross/converter_main.cc b/o3d/converter/cross/converter_main.cc
index ee819a9..fda6907 100644
--- a/o3d/converter/cross/converter_main.cc
+++ b/o3d/converter/cross/converter_main.cc
@@ -78,16 +78,16 @@ int CrossMain(int argc, char**argv) {
o3d::UTF8ToFilePath("convert.py"));
- std::vector<std::wstring> values = command_line->GetLooseValues();
+ const std::vector<CommandLine::StringType>& values = command_line->args();
if (values.size() == 1) {
// If we're only given one argument, then construct the output
// filename by substituting the extension on the filename (if any)
// with .o3dtgz.
- in_filename = o3d::WideToFilePath(values[0]);
+ in_filename = FilePath(values[0]);
out_filename = in_filename.ReplaceExtension(FILE_PATH_LITERAL(".o3dtgz"));
} else if (values.size()== 2) {
- in_filename = o3d::WideToFilePath(values[0]);
- out_filename = o3d::WideToFilePath(values[1]);
+ in_filename = FilePath(values[0]);
+ out_filename = FilePath(values[1]);
} else {
std::cerr << "Usage: " << argv[0]
<< " [ options ] <infile.dae> [ <outfile> ]\n";
diff --git a/o3d/converter/cross/verifier_main.cc b/o3d/converter/cross/verifier_main.cc
index 931fa39..1f7280c 100644
--- a/o3d/converter/cross/verifier_main.cc
+++ b/o3d/converter/cross/verifier_main.cc
@@ -69,12 +69,12 @@ int CrossMain(int argc, char**argv) {
FilePath in_filename, out_filename;
- std::vector<std::wstring> values = command_line->GetLooseValues();
+ const std::vector<CommandLine::StringType>& values = args->args();
if (values.size() == 1) {
- in_filename = o3d::WideToFilePath(values[0]);
+ in_filename = FilePath(values[0]);
} else if (values.size()== 2) {
- in_filename = o3d::WideToFilePath(values[0]);
- out_filename = o3d::WideToFilePath(values[1]);
+ in_filename = FilePath(values[0]);
+ out_filename = FilePath(values[1]);
} else {
std::cerr << "Usage: " << FilePath(argv[0]).BaseName().value()
<< " [--no-condition] <infile.fx> [<outfile.fx>]\n";
diff --git a/o3d/converter_edge/cross/converter_main.cc b/o3d/converter_edge/cross/converter_main.cc
index eef1dec..7fc033a 100644
--- a/o3d/converter_edge/cross/converter_main.cc
+++ b/o3d/converter_edge/cross/converter_main.cc
@@ -70,16 +70,16 @@ int CrossMain(int argc, char**argv) {
FilePath in_filename, out_filename;
- std::vector<std::wstring> values = command_line->GetLooseValues();
+ const std::vector<CommandLine::StringType>& values = command_line->args();
if (values.size() == 1) {
// If we're only given one argument, then construct the output
// filename by substituting the extension on the filename (if any)
// with .o3dtgz.
- in_filename = o3d::WideToFilePath(values[0]);
+ in_filename = FilePath(values[0]);
out_filename = in_filename.ReplaceExtension(FILE_PATH_LITERAL(".o3dtgz"));
} else if (values.size()== 2) {
- in_filename = o3d::WideToFilePath(values[0]);
- out_filename = o3d::WideToFilePath(values[1]);
+ in_filename = FilePath(values[0]);
+ out_filename = FilePath(values[1]);
} else {
std::cerr << "Usage: " << argv[0]
<< " [ options ] <infile.dae> [ <outfile> ]\n";
diff --git a/o3d/converter_edge/cross/verifier_main.cc b/o3d/converter_edge/cross/verifier_main.cc
index c401596..5c2b954 100644
--- a/o3d/converter_edge/cross/verifier_main.cc
+++ b/o3d/converter_edge/cross/verifier_main.cc
@@ -69,12 +69,12 @@ int CrossMain(int argc, char**argv) {
FilePath in_filename, out_filename;
- std::vector<std::wstring> values = command_line->GetLooseValues();
+ const std::vector<CommandLine::StringType>& values = command_line->args();
if (values.size() == 1) {
- in_filename = o3d::WideToFilePath(values[0]);
+ in_filename = FilePath(values[0]);
} else if (values.size()== 2) {
- in_filename = o3d::WideToFilePath(values[0]);
- out_filename = o3d::WideToFilePath(values[1]);
+ in_filename = FilePath(values[0]);
+ out_filename = FilePath(values[1]);
} else {
std::cerr << "Usage: " << FilePath(argv[0]).BaseName().value()
<< " [--no-condition] <infile.fx> [<outfile.fx>]\n";
diff --git a/tools/imagediff/image_diff.cc b/tools/imagediff/image_diff.cc
index d755b6f..ccf356c 100644
--- a/tools/imagediff/image_diff.cc
+++ b/tools/imagediff/image_diff.cc
@@ -363,19 +363,15 @@ int main(int argc, const char* argv[]) {
return 0;
}
- // TODO: CommandLine::GetLooseValues() should eventually return
- // CommandLine::StringType (which is the same as
- // FilePath::StringType and can convert to FilePaths directly).
- std::vector<std::wstring> values = parsed_command_line.GetLooseValues();
+ const std::vector<CommandLine::StringType>& args = parsed_command_line.args();
if (parsed_command_line.HasSwitch(kOptionGenerateDiff)) {
- if (values.size() == 3) {
- return DiffImages(FilePath::FromWStringHack(values[0]),
- FilePath::FromWStringHack(values[1]),
- FilePath::FromWStringHack(values[2]));
+ if (args.size() == 3) {
+ return DiffImages(FilePath(args[0]),
+ FilePath(args[1]),
+ FilePath(args[2]));
}
- } else if (values.size() == 2) {
- return CompareImages(FilePath::FromWStringHack(values[0]),
- FilePath::FromWStringHack(values[1]));
+ } else if (args.size() == 2) {
+ return CompareImages(FilePath(args[0]), FilePath(args[1]));
}
PrintHelp();
diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc
index 203265d..4a5cc46 100644
--- a/webkit/tools/test_shell/test_shell_main.cc
+++ b/webkit/tools/test_shell/test_shell_main.cc
@@ -209,7 +209,7 @@ int main(int argc, char* argv[]) {
TestShell::SetFileTestTimeout(timeout_ms);
}
- // Treat the first loose value as the initial URL to open.
+ // Treat the first argument as the initial URL to open.
GURL starting_url;
// Default to a homepage if we're interactive.
@@ -223,14 +223,14 @@ int main(int argc, char* argv[]) {
starting_url = net::FilePathToFileURL(path);
}
- std::vector<std::wstring> loose_values = parsed_command_line.GetLooseValues();
- if (loose_values.size() > 0) {
- GURL url(WideToUTF16Hack(loose_values[0]));
+ const std::vector<CommandLine::StringType>& args = parsed_command_line.args();
+ if (args.size() > 0) {
+ GURL url(args[0]);
if (url.is_valid()) {
starting_url = url;
} else {
// Treat as a relative file path.
- FilePath path = FilePath::FromWStringHack(loose_values[0]);
+ FilePath path = FilePath(args[0]);
file_util::AbsolutePath(&path);
starting_url = net::FilePathToFileURL(path);
}
@@ -358,7 +358,7 @@ int main(int argc, char* argv[]) {
} else {
// TODO(ojan): Provide a way for run-singly tests to pass
// in a hash and then set params.pixel_hash here.
- params.test_url = WideToUTF8(loose_values[0]);
+ params.test_url = starting_url.spec();
TestShell::RunFileTest(params);
}