Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: chrome/installer/util/delete_after_reboot_helper.cc

Issue 19052005: Move PathIsWritable, DirectoryExists, ContentsEqual, and TextContentsEqual to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Must only be called for regular files or directories that will be empty. 56 // Must only be called for regular files or directories that will be empty.
57 bool ScheduleFileSystemEntityForDeletion(const wchar_t* path) { 57 bool ScheduleFileSystemEntityForDeletion(const wchar_t* path) {
58 // Check if the file exists, return false if not. 58 // Check if the file exists, return false if not.
59 WIN32_FILE_ATTRIBUTE_DATA attrs = {0}; 59 WIN32_FILE_ATTRIBUTE_DATA attrs = {0};
60 if (!::GetFileAttributesEx(path, ::GetFileExInfoStandard, &attrs)) { 60 if (!::GetFileAttributesEx(path, ::GetFileExInfoStandard, &attrs)) {
61 PLOG(WARNING) << path << " does not exist."; 61 PLOG(WARNING) << path << " does not exist.";
62 return false; 62 return false;
63 } 63 }
64 64
65 DWORD flags = MOVEFILE_DELAY_UNTIL_REBOOT; 65 DWORD flags = MOVEFILE_DELAY_UNTIL_REBOOT;
66 if (!file_util::DirectoryExists(base::FilePath::FromWStringHack(path))) { 66 if (!base::DirectoryExists(base::FilePath::FromWStringHack(path))) {
67 // This flag valid only for files 67 // This flag valid only for files
68 flags |= MOVEFILE_REPLACE_EXISTING; 68 flags |= MOVEFILE_REPLACE_EXISTING;
69 } 69 }
70 70
71 if (!::MoveFileEx(path, NULL, flags)) { 71 if (!::MoveFileEx(path, NULL, flags)) {
72 PLOG(ERROR) << "Could not schedule " << path << " for deletion."; 72 PLOG(ERROR) << "Could not schedule " << path << " for deletion.";
73 return false; 73 return false;
74 } 74 }
75 75
76 #ifndef NDEBUG 76 #ifndef NDEBUG
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 ERROR_SUCCESS); 384 ERROR_SUCCESS);
385 } 385 }
386 std::vector<char> buffer; 386 std::vector<char> buffer;
387 StringArrayToMultiSZBytes(strings_to_keep, &buffer); 387 StringArrayToMultiSZBytes(strings_to_keep, &buffer);
388 DCHECK_GT(buffer.size(), 0U); 388 DCHECK_GT(buffer.size(), 0U);
389 if (buffer.empty()) 389 if (buffer.empty())
390 return false; 390 return false;
391 return (session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], 391 return (session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0],
392 buffer.size(), REG_MULTI_SZ) == ERROR_SUCCESS); 392 buffer.size(), REG_MULTI_SZ) == ERROR_SUCCESS);
393 } 393 }
OLDNEW
« no previous file with comments | « chrome/installer/util/copy_tree_work_item_unittest.cc ('k') | chrome/installer/util/move_tree_work_item_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698