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

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

Issue 271099: Re-try r29078: Remove some deprecated file_util wstring functions. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // Must only be called for regular files or directories that will be empty. 57 // Must only be called for regular files or directories that will be empty.
58 bool ScheduleFileSystemEntityForDeletion(const wchar_t* path) { 58 bool ScheduleFileSystemEntityForDeletion(const wchar_t* path) {
59 // Check if the file exists, return false if not. 59 // Check if the file exists, return false if not.
60 WIN32_FILE_ATTRIBUTE_DATA attrs = {0}; 60 WIN32_FILE_ATTRIBUTE_DATA attrs = {0};
61 if (!::GetFileAttributesEx(path, ::GetFileExInfoStandard, &attrs)) { 61 if (!::GetFileAttributesEx(path, ::GetFileExInfoStandard, &attrs)) {
62 LOG(ERROR) << path << " for deletion does not exist." << GetLastError(); 62 LOG(ERROR) << path << " for deletion does not exist." << GetLastError();
63 return false; 63 return false;
64 } 64 }
65 65
66 DWORD flags = MOVEFILE_DELAY_UNTIL_REBOOT; 66 DWORD flags = MOVEFILE_DELAY_UNTIL_REBOOT;
67 if (!file_util::DirectoryExists(path)) { 67 if (!file_util::DirectoryExists(FilePath::FromWStringHack(path))) {
68 // This flag valid only for files 68 // This flag valid only for files
69 flags |= MOVEFILE_REPLACE_EXISTING; 69 flags |= MOVEFILE_REPLACE_EXISTING;
70 } 70 }
71 71
72 if (!::MoveFileEx(path, NULL, flags)) { 72 if (!::MoveFileEx(path, NULL, flags)) {
73 LOG(ERROR) << "Could not schedule " << path << " for deletion."; 73 LOG(ERROR) << "Could not schedule " << path << " for deletion.";
74 return false; 74 return false;
75 } 75 }
76 76
77 LOG(INFO) << "Scheduled for deletion: " << path; 77 LOG(INFO) << "Scheduled for deletion: " << path;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], 366 return session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0],
367 buffer.size(), REG_MULTI_SZ); 367 buffer.size(), REG_MULTI_SZ);
368 } else { 368 } else {
369 return false; 369 return false;
370 } 370 }
371 } else { 371 } else {
372 // We have only the trailing NULL string. Don't bother writing that. 372 // We have only the trailing NULL string. Don't bother writing that.
373 return session_manager_key.DeleteValue(kPendingFileRenameOps); 373 return session_manager_key.DeleteValue(kPendingFileRenameOps);
374 } 374 }
375 } 375 }
OLDNEW
« no previous file with comments | « chrome/installer/util/copy_tree_work_item_unittest.cc ('k') | chrome/installer/util/delete_tree_work_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698