| Index: chrome/installer/util/delete_tree_work_item.cc
|
| ===================================================================
|
| --- chrome/installer/util/delete_tree_work_item.cc (revision 29088)
|
| +++ chrome/installer/util/delete_tree_work_item.cc (working copy)
|
| @@ -7,13 +7,17 @@
|
| #include "chrome/installer/util/delete_tree_work_item.h"
|
|
|
| DeleteTreeWorkItem::~DeleteTreeWorkItem() {
|
| - std::wstring tmp_dir = file_util::GetDirectoryFromPath(backup_path_);
|
| - if (file_util::PathExists(tmp_dir)) {
|
| - file_util::Delete(tmp_dir, true);
|
| + if (!backup_path_.empty()) {
|
| + FilePath tmp_dir = backup_path_.DirName();
|
| + if (file_util::PathExists(tmp_dir)) {
|
| + file_util::Delete(tmp_dir, true);
|
| + }
|
| }
|
| - tmp_dir = file_util::GetDirectoryFromPath(key_backup_path_);
|
| - if (file_util::PathExists(tmp_dir)) {
|
| - file_util::Delete(tmp_dir, true);
|
| + if (!key_backup_path_.empty()) {
|
| + FilePath tmp_dir = key_backup_path_.DirName();
|
| + if (file_util::PathExists(tmp_dir)) {
|
| + file_util::Delete(tmp_dir, true);
|
| + }
|
| }
|
| }
|
|
|
| @@ -30,8 +34,8 @@
|
| if (!GetBackupPath(key_path_, &key_backup_path_) ||
|
| !file_util::CopyDirectory(key_path_, key_backup_path_, true) ||
|
| !file_util::Delete(key_path_, true)) {
|
| - LOG(ERROR) << "can not delete " << key_path_
|
| - << " OR copy it to backup path " << key_backup_path_;
|
| + LOG(ERROR) << "can not delete " << key_path_.value()
|
| + << " OR copy it to backup path " << key_backup_path_.value();
|
| return false;
|
| }
|
| }
|
| @@ -40,8 +44,8 @@
|
| if (!GetBackupPath(root_path_, &backup_path_) ||
|
| !file_util::CopyDirectory(root_path_, backup_path_, true) ||
|
| !file_util::Delete(root_path_, true)) {
|
| - LOG(ERROR) << "can not delete " << root_path_
|
| - << " OR copy it to backup path " << backup_path_;
|
| + LOG(ERROR) << "can not delete " << root_path_.value()
|
| + << " OR copy it to backup path " << backup_path_.value();
|
| return false;
|
| }
|
| }
|
| @@ -58,15 +62,14 @@
|
| }
|
| }
|
|
|
| -bool DeleteTreeWorkItem::GetBackupPath(const std::wstring& for_path,
|
| - std::wstring* backup_path) {
|
| +bool DeleteTreeWorkItem::GetBackupPath(const FilePath& for_path,
|
| + FilePath* backup_path) {
|
| if (!file_util::CreateNewTempDirectory(L"", backup_path)) {
|
| // We assume that CreateNewTempDirectory() is doing its job well.
|
| LOG(ERROR) << "Couldn't get backup path for delete.";
|
| return false;
|
| }
|
| - std::wstring file_name = file_util::GetFilenameFromPath(for_path);
|
| - file_util::AppendToPath(backup_path, file_name);
|
|
|
| + *backup_path = backup_path->Append(for_path.BaseName());
|
| return true;
|
| }
|
|
|