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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 // We should never run off the end while in this loop. | 241 // We should never run off the end while in this loop. |
242 DCHECK(write_pointer < end_pointer); | 242 DCHECK(write_pointer < end_pointer); |
243 } | 243 } |
244 *write_pointer = L'\0'; // Explicitly set the final null char. | 244 *write_pointer = L'\0'; // Explicitly set the final null char. |
245 DCHECK(++write_pointer == end_pointer); | 245 DCHECK(++write_pointer == end_pointer); |
246 } | 246 } |
247 | 247 |
248 base::FilePath GetShortPathName(const base::FilePath& path) { | 248 base::FilePath GetShortPathName(const base::FilePath& path) { |
249 std::wstring short_path; | 249 std::wstring short_path; |
250 DWORD length = GetShortPathName(path.value().c_str(), | 250 DWORD length = GetShortPathName(path.value().c_str(), |
251 WriteInto(&short_path, MAX_PATH), | 251 base::WriteInto(&short_path, MAX_PATH), |
252 MAX_PATH); | 252 MAX_PATH); |
253 DWORD last_error = ::GetLastError(); | 253 DWORD last_error = ::GetLastError(); |
254 DLOG_IF(WARNING, length == 0 && last_error != ERROR_PATH_NOT_FOUND) | 254 DLOG_IF(WARNING, length == 0 && last_error != ERROR_PATH_NOT_FOUND) |
255 << __FUNCTION__ << " gle=" << last_error; | 255 << __FUNCTION__ << " gle=" << last_error; |
256 if (length == 0) { | 256 if (length == 0) { |
257 // GetShortPathName fails if the path is no longer present. Instead of | 257 // GetShortPathName fails if the path is no longer present. Instead of |
258 // returning an empty string, just return the original string. This will | 258 // returning an empty string, just return the original string. This will |
259 // serve our purposes. | 259 // serve our purposes. |
260 return path; | 260 return path; |
261 } | 261 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 ERROR_SUCCESS); | 397 ERROR_SUCCESS); |
398 } | 398 } |
399 std::vector<char> buffer; | 399 std::vector<char> buffer; |
400 StringArrayToMultiSZBytes(strings_to_keep, &buffer); | 400 StringArrayToMultiSZBytes(strings_to_keep, &buffer); |
401 DCHECK_GT(buffer.size(), 0U); | 401 DCHECK_GT(buffer.size(), 0U); |
402 if (buffer.empty()) | 402 if (buffer.empty()) |
403 return false; | 403 return false; |
404 return (session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], | 404 return (session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], |
405 buffer.size(), REG_MULTI_SZ) == ERROR_SUCCESS); | 405 buffer.size(), REG_MULTI_SZ) == ERROR_SUCCESS); |
406 } | 406 } |
OLD | NEW |