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

Unified Diff: chrome/installer/util/copy_tree_work_item.cc

Issue 280004: Revert wstring patch (r29078 and follow up commits). It is causing failures o... (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/util/copy_tree_work_item.h ('k') | chrome/installer/util/copy_tree_work_item_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/copy_tree_work_item.cc
===================================================================
--- chrome/installer/util/copy_tree_work_item.cc (revision 29084)
+++ chrome/installer/util/copy_tree_work_item.cc (working copy)
@@ -31,7 +31,7 @@
bool CopyTreeWorkItem::Do() {
if (!file_util::PathExists(source_path_)) {
- LOG(ERROR) << source_path_.value() << " does not exist";
+ LOG(ERROR) << source_path_ << " does not exist";
return false;
}
@@ -39,29 +39,29 @@
// handle overwrite_option_ = IF_DIFFERENT case.
if ((dest_exist) &&
(overwrite_option_ == WorkItem::IF_DIFFERENT) && // only for single file
- (!file_util::DirectoryExists(source_path_)) &&
- (!file_util::DirectoryExists(dest_path_)) &&
+ (!PathIsDirectory(source_path_.c_str())) &&
+ (!PathIsDirectory(dest_path_.c_str())) &&
(file_util::ContentsEqual(source_path_, dest_path_))) {
- LOG(INFO) << "Source file " << source_path_.value()
- << " and destination file " << dest_path_.value()
+ LOG(INFO) << "Source file " << source_path_
+ << " and destination file " << dest_path_
<< " are exactly same. Returning true.";
return true;
} else if ((dest_exist) &&
(overwrite_option_ == WorkItem::NEW_NAME_IF_IN_USE) &&
- (!file_util::DirectoryExists(source_path_)) &&
- (!file_util::DirectoryExists(dest_path_)) &&
+ (!PathIsDirectory(source_path_.c_str())) &&
+ (!PathIsDirectory(dest_path_.c_str())) &&
(IsFileInUse(dest_path_))) {
// handle overwrite_option_ = NEW_NAME_IF_IN_USE case.
if (alternative_path_.empty() ||
file_util::PathExists(alternative_path_) ||
!file_util::CopyFile(source_path_, alternative_path_)) {
- LOG(ERROR) << "failed to copy " << source_path_.value() <<
- " to " << alternative_path_.value();
+ LOG(ERROR) << "failed to copy " << source_path_ <<
+ " to " << alternative_path_;
return false;
} else {
copied_to_alternate_path_ = true;
- LOG(INFO) << "Copied source file " << source_path_.value()
- << " to alternative path " << alternative_path_.value();
+ LOG(INFO) << "Copied source file " << source_path_
+ << " to alternative path " << alternative_path_;
return true;
}
} else if ((dest_exist) &&
@@ -77,11 +77,10 @@
if (file_util::Move(dest_path_, backup_path_)) {
moved_to_backup_ = true;
- LOG(INFO) << "Moved destination " << dest_path_.value() <<
- " to backup path " << backup_path_.value();
+ LOG(INFO) << "Moved destination " << dest_path_
+ << " to backup path " << backup_path_;
} else {
- LOG(ERROR) << "failed moving " << dest_path_.value() << " to " <<
- backup_path_.value();
+ LOG(ERROR) << "failed moving " << dest_path_ << " to " << backup_path_;
return false;
}
}
@@ -89,11 +88,10 @@
// In all cases that reach here, copy source to destination.
if (file_util::CopyDirectory(source_path_, dest_path_, true)) {
copied_to_dest_path_ = true;
- LOG(INFO) << "Copied source " << source_path_.value()
- << " to destination " << dest_path_.value();
+ LOG(INFO) << "Copied source " << source_path_
+ << " to destination " << dest_path_;
} else {
- LOG(ERROR) << "failed copy " << source_path_.value() <<
- " to " << dest_path_.value();
+ LOG(ERROR) << "failed copy " << source_path_ << " to " << dest_path_;
return false;
}
@@ -107,23 +105,22 @@
// Delete here. For now we just log the error and continue with the
// rest of rollback operation.
if (copied_to_dest_path_ && !file_util::Delete(dest_path_, true)) {
- LOG(ERROR) << "Can not delete " << dest_path_.value();
+ LOG(ERROR) << "Can not delete " << dest_path_;
}
if (moved_to_backup_ && !file_util::Move(backup_path_, dest_path_)) {
- LOG(ERROR) << "failed move " << backup_path_.value() << " to " <<
- dest_path_.value();
+ LOG(ERROR) << "failed move " << backup_path_ << " to " << dest_path_;
}
if (copied_to_alternate_path_ &&
!file_util::Delete(alternative_path_, true)) {
- LOG(ERROR) << "Can not delete " << alternative_path_.value();
+ LOG(ERROR) << "Can not delete " << alternative_path_;
}
}
-bool CopyTreeWorkItem::IsFileInUse(const FilePath& path) {
+bool CopyTreeWorkItem::IsFileInUse(const std::wstring& path) {
if (!file_util::PathExists(path))
return false;
- HANDLE handle = ::CreateFile(path.value().c_str(), FILE_ALL_ACCESS,
+ HANDLE handle = ::CreateFile(path.c_str(), FILE_ALL_ACCESS,
NULL, NULL, OPEN_EXISTING, NULL, NULL);
if (handle == INVALID_HANDLE_VALUE)
return true;
@@ -133,14 +130,16 @@
}
bool CopyTreeWorkItem::GetBackupPath() {
- backup_path_ = temp_dir_.Append(dest_path_.BaseName());
+ std::wstring file_name = file_util::GetFilenameFromPath(dest_path_);
+ backup_path_.assign(temp_dir_);
+ file_util::AppendToPath(&backup_path_, file_name);
if (file_util::PathExists(backup_path_)) {
// Ideally we should not fail immediately. Instead we could try some
// random paths under temp_dir_ until we reach certain limit.
// For now our caller always provides a good temporary directory so
// we don't bother.
- LOG(ERROR) << "backup path " << backup_path_.value() << " already exists";
+ LOG(ERROR) << "backup path " << backup_path_ << " already exists";
return false;
}
« no previous file with comments | « chrome/installer/util/copy_tree_work_item.h ('k') | chrome/installer/util/copy_tree_work_item_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698