Chromium Code Reviews| 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 // 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 Loading... | |
| 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"\"\""); |
|
grt (UTC plus 2)
2011/05/11 14:27:32
No whitespace is put between the pair of double qu
msw
2011/05/12 00:37:47
Done and tests pass. This refactoring is entirely
| |
| 364 // Return a bunch of nothingness. | 364 *command_line = CommandLine::FromString(program + arguments); |
| 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 } |
| OLD | NEW |