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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 base::WriteInto(&short_path, MAX_PATH), | 251 base::WriteInto(&short_path, MAX_PATH), |
252 MAX_PATH); | 252 MAX_PATH); |
253 DWORD last_error = ::GetLastError(); | 253 DPLOG_IF(WARNING, length == 0 && GetLastError() != ERROR_PATH_NOT_FOUND) |
254 DLOG_IF(WARNING, length == 0 && last_error != ERROR_PATH_NOT_FOUND) | 254 << __func__; |
255 << __FUNCTION__ << " gle=" << last_error; | |
256 if ((length == 0) || (length > MAX_PATH)) { | 255 if ((length == 0) || (length > MAX_PATH)) { |
257 // GetShortPathName fails if the path is no longer present or cannot be | 256 // GetShortPathName fails if the path is no longer present or cannot be |
258 // put in the size buffer provided. Instead of returning an empty string, | 257 // put in the size buffer provided. Instead of returning an empty string, |
259 // just return the original string. This will serve our purposes. | 258 // just return the original string. This will serve our purposes. |
260 return path; | 259 return path; |
261 } | 260 } |
262 | 261 |
263 short_path.resize(length); | 262 short_path.resize(length); |
264 return base::FilePath(short_path); | 263 return base::FilePath(short_path); |
265 } | 264 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 ERROR_SUCCESS); | 396 ERROR_SUCCESS); |
398 } | 397 } |
399 std::vector<char> buffer; | 398 std::vector<char> buffer; |
400 StringArrayToMultiSZBytes(strings_to_keep, &buffer); | 399 StringArrayToMultiSZBytes(strings_to_keep, &buffer); |
401 DCHECK_GT(buffer.size(), 0U); | 400 DCHECK_GT(buffer.size(), 0U); |
402 if (buffer.empty()) | 401 if (buffer.empty()) |
403 return false; | 402 return false; |
404 return (session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], | 403 return (session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], |
405 buffer.size(), REG_MULTI_SZ) == ERROR_SUCCESS); | 404 buffer.size(), REG_MULTI_SZ) == ERROR_SUCCESS); |
406 } | 405 } |
OLD | NEW |