OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This file defines helper methods used to schedule files for deletion | 5 // This file defines helper methods used to schedule files for deletion |
6 // on next reboot. The code here is heavily borrowed and simplified from | 6 // on next reboot. The code here is heavily borrowed and simplified from |
7 // http://code.google.com/p/omaha/source/browse/trunk/common/file.cc and | 7 // http://code.google.com/p/omaha/source/browse/trunk/common/file.cc and |
8 // http://code.google.com/p/omaha/source/browse/trunk/common/utils.cc | 8 // http://code.google.com/p/omaha/source/browse/trunk/common/utils.cc |
9 // | 9 // |
10 // This implementation really is not fast, so do not use it where that will | 10 // This implementation really is not fast, so do not use it where that will |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 return hr; | 323 return hr; |
324 } | 324 } |
325 | 325 |
326 bool MatchPendingDeletePath(const base::FilePath& short_form_needle, | 326 bool MatchPendingDeletePath(const base::FilePath& short_form_needle, |
327 const base::FilePath& reg_path) { | 327 const base::FilePath& reg_path) { |
328 // Stores the path stored in each entry. | 328 // Stores the path stored in each entry. |
329 std::wstring match_path(reg_path.value()); | 329 std::wstring match_path(reg_path.value()); |
330 | 330 |
331 // First chomp the prefix since that will mess up GetShortPathName. | 331 // First chomp the prefix since that will mess up GetShortPathName. |
332 std::wstring prefix(L"\\??\\"); | 332 std::wstring prefix(L"\\??\\"); |
333 if (StartsWith(match_path, prefix, false)) | 333 if (base::StartsWith(match_path, prefix, false)) |
334 match_path = match_path.substr(4); | 334 match_path = match_path.substr(4); |
335 | 335 |
336 // Get the short path name of the entry. | 336 // Get the short path name of the entry. |
337 base::FilePath short_match_path(GetShortPathName(base::FilePath(match_path))); | 337 base::FilePath short_match_path(GetShortPathName(base::FilePath(match_path))); |
338 | 338 |
339 // Now compare the paths. If it isn't one we're looking for, add it | 339 // Now compare the paths. If it isn't one we're looking for, add it |
340 // to the list to keep. | 340 // to the list to keep. |
341 return StartsWith(short_match_path.value(), short_form_needle.value(), false); | 341 return base::StartsWith(short_match_path.value(), short_form_needle.value(), |
| 342 false); |
342 } | 343 } |
343 | 344 |
344 // Removes all pending moves for the given |directory| and any contained | 345 // Removes all pending moves for the given |directory| and any contained |
345 // files or subdirectories. Returns true on success | 346 // files or subdirectories. Returns true on success |
346 bool RemoveFromMovesPendingReboot(const base::FilePath& directory) { | 347 bool RemoveFromMovesPendingReboot(const base::FilePath& directory) { |
347 std::vector<PendingMove> pending_moves; | 348 std::vector<PendingMove> pending_moves; |
348 HRESULT hr = GetPendingMovesValue(&pending_moves); | 349 HRESULT hr = GetPendingMovesValue(&pending_moves); |
349 if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) { | 350 if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) { |
350 // No pending moves, nothing to do. | 351 // No pending moves, nothing to do. |
351 return true; | 352 return true; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 ERROR_SUCCESS); | 390 ERROR_SUCCESS); |
390 } | 391 } |
391 std::vector<char> buffer; | 392 std::vector<char> buffer; |
392 StringArrayToMultiSZBytes(strings_to_keep, &buffer); | 393 StringArrayToMultiSZBytes(strings_to_keep, &buffer); |
393 DCHECK_GT(buffer.size(), 0U); | 394 DCHECK_GT(buffer.size(), 0U); |
394 if (buffer.empty()) | 395 if (buffer.empty()) |
395 return false; | 396 return false; |
396 return (session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], | 397 return (session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], |
397 buffer.size(), REG_MULTI_SZ) == ERROR_SUCCESS); | 398 buffer.size(), REG_MULTI_SZ) == ERROR_SUCCESS); |
398 } | 399 } |
OLD | NEW |