| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 } | 237 } |
| 238 *write_pointer = L'\0'; // Explicitly set the final null char. | 238 *write_pointer = L'\0'; // Explicitly set the final null char. |
| 239 DCHECK(++write_pointer == end_pointer); | 239 DCHECK(++write_pointer == end_pointer); |
| 240 } | 240 } |
| 241 | 241 |
| 242 std::wstring GetShortPathName(const wchar_t* path) { | 242 std::wstring GetShortPathName(const wchar_t* path) { |
| 243 std::wstring short_path; | 243 std::wstring short_path; |
| 244 DWORD length = GetShortPathName(path, WriteInto(&short_path, MAX_PATH), | 244 DWORD length = GetShortPathName(path, WriteInto(&short_path, MAX_PATH), |
| 245 MAX_PATH); | 245 MAX_PATH); |
| 246 DLOG_IF(WARNING, length == 0) << __FUNCTION__ << " gle=" << GetLastError(); | 246 DLOG_IF(WARNING, length == 0) << __FUNCTION__ << " gle=" << GetLastError(); |
| 247 if (length == 0) { |
| 248 // GetShortPathName fails if the path is no longer present. Instead of |
| 249 // returning an empty string, just return the original string. This will |
| 250 // serve for our purposes. |
| 251 return path; |
| 252 } |
| 253 |
| 247 short_path.resize(length); | 254 short_path.resize(length); |
| 248 return short_path; | 255 return short_path; |
| 249 } | 256 } |
| 250 | 257 |
| 251 HRESULT GetPendingMovesValue( | 258 HRESULT GetPendingMovesValue( |
| 252 std::vector<PendingMove>* pending_moves) { | 259 std::vector<PendingMove>* pending_moves) { |
| 253 DCHECK(pending_moves); | 260 DCHECK(pending_moves); |
| 254 pending_moves->clear(); | 261 pending_moves->clear(); |
| 255 | 262 |
| 256 // Get the current value of the key | 263 // Get the current value of the key |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 return session_manager_key.DeleteValue(kPendingFileRenameOps); | 380 return session_manager_key.DeleteValue(kPendingFileRenameOps); |
| 374 } | 381 } |
| 375 std::vector<char> buffer; | 382 std::vector<char> buffer; |
| 376 StringArrayToMultiSZBytes(strings_to_keep, &buffer); | 383 StringArrayToMultiSZBytes(strings_to_keep, &buffer); |
| 377 DCHECK(buffer.size() > 0); | 384 DCHECK(buffer.size() > 0); |
| 378 if (buffer.empty()) | 385 if (buffer.empty()) |
| 379 return false; | 386 return false; |
| 380 return session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], | 387 return session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], |
| 381 buffer.size(), REG_MULTI_SZ); | 388 buffer.size(), REG_MULTI_SZ); |
| 382 } | 389 } |
| OLD | NEW |