Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: chrome/installer/util/install_util.cc

Issue 6526040: CommandLine refactoring and cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Major refresh after r76339 and r76419. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // See the corresponding header file for description of the functions in this 5 // See the corresponding header file for description of the functions in this
6 // file. 6 // file.
7 7
8 #include "chrome/installer/util/install_util.h" 8 #include "chrome/installer/util/install_util.h"
9 9
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return 0; 352 return 0;
353 default: 353 default:
354 return status; 354 return status;
355 } 355 }
356 } 356 }
357 357
358 // static 358 // static
359 void InstallUtil::MakeUninstallCommand(const std::wstring& exe_path, 359 void InstallUtil::MakeUninstallCommand(const std::wstring& exe_path,
360 const std::wstring& arguments, 360 const std::wstring& arguments,
361 CommandLine* command_line) { 361 CommandLine* command_line) {
362 const bool no_program = exe_path.empty(); 362 // Surround non-empty program name with simple quotes.
363 363 std::wstring program(!exe_path.empty() ? L"\"" + exe_path + L"\" " : L"\"\"");
364 // Return a bunch of nothingness. 364 *command_line = CommandLine::FromString(program + arguments);
Evan Martin 2011/05/10 23:48:32 This is a little bit terrifying to me. How certai
msw 2011/05/11 02:28:12 I agree that this isn't robust quoting/escaping, b
365 if (no_program && arguments.empty()) {
366 *command_line = CommandLine(CommandLine::NO_PROGRAM);
367 } else {
368 // Form a full command line string.
369 std::wstring command;
370 command.append(1, L'"')
371 .append(no_program ? L"" : exe_path)
372 .append(L"\" ")
373 .append(arguments);
374
375 // If we have a program name, return this complete command line.
376 *command_line = CommandLine::FromString(command);
377 }
378 } 365 }
379 366
380 std::wstring InstallUtil::GetCurrentDate() { 367 std::wstring InstallUtil::GetCurrentDate() {
381 static const wchar_t kDateFormat[] = L"yyyyMMdd"; 368 static const wchar_t kDateFormat[] = L"yyyyMMdd";
382 wchar_t date_str[arraysize(kDateFormat)] = {0}; 369 wchar_t date_str[arraysize(kDateFormat)] = {0};
383 int len = GetDateFormatW(LOCALE_INVARIANT, 0, NULL, kDateFormat, 370 int len = GetDateFormatW(LOCALE_INVARIANT, 0, NULL, kDateFormat,
384 date_str, arraysize(date_str)); 371 date_str, arraysize(date_str));
385 if (len) { 372 if (len) {
386 --len; // Subtract terminating \0. 373 --len; // Subtract terminating \0.
387 } else { 374 } else {
388 PLOG(DFATAL) << "GetDateFormat"; 375 PLOG(DFATAL) << "GetDateFormat";
389 } 376 }
390 377
391 return std::wstring(date_str, len); 378 return std::wstring(date_str, len);
392 } 379 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698