summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util/installer_state.cc
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-26 17:16:14 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-26 17:16:14 +0000
commit9fe4eea2d85c2aa7c36d420f7738be7a6dbc1f61 (patch)
tree12b3afae8aed3578b4e74818e9b92e1b68c40711 /chrome/installer/util/installer_state.cc
parent5f0e88b4a552c9fb5b953c4495b652d0559be977 (diff)
downloadchromium_src-9fe4eea2d85c2aa7c36d420f7738be7a6dbc1f61.zip
chromium_src-9fe4eea2d85c2aa7c36d420f7738be7a6dbc1f61.tar.gz
chromium_src-9fe4eea2d85c2aa7c36d420f7738be7a6dbc1f61.tar.bz2
IsFileInUse should return false when the directory doesn't exist, too.
BUG=98195 TEST=install chrome, delete the installation dir without uninstalling, then install again. hope that chrome.exe is in place rather than new_chrome.exe. Review URL: https://chromiumcodereview.appspot.com/11416161 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169440 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/installer_state.cc')
-rw-r--r--chrome/installer/util/installer_state.cc16
1 files changed, 6 insertions, 10 deletions
diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc
index ff3eb5a..61c34794 100644
--- a/chrome/installer/util/installer_state.cc
+++ b/chrome/installer/util/installer_state.cc
@@ -16,6 +16,7 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/win/registry.h"
+#include "base/win/scoped_handle.h"
#include "chrome/installer/util/delete_tree_work_item.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/install_util.h"
@@ -584,7 +585,8 @@ bool InstallerState::IsChromeFrameRunning(
FilePath cf_install_path(
target_path().AppendASCII(current_version->GetString())
.Append(kChromeFrameDll));
- in_use = IsFileInUse(cf_install_path);
+ in_use = file_util::PathExists(cf_install_path) &&
+ IsFileInUse(cf_install_path);
}
return in_use;
}
@@ -598,17 +600,11 @@ FilePath InstallerState::GetInstallerDirectory(const Version& version) const {
bool InstallerState::IsFileInUse(const FilePath& file) {
// Call CreateFile with a share mode of 0 which should cause this to fail
// with ERROR_SHARING_VIOLATION if the file exists and is in-use.
- HANDLE file_handle = CreateFile(file.value().c_str(), GENERIC_WRITE, 0, NULL,
- OPEN_EXISTING, 0, 0);
- bool in_use = false;
- if (file_handle != INVALID_HANDLE_VALUE)
- CloseHandle(file_handle);
- else if (GetLastError() != ERROR_FILE_NOT_FOUND)
- in_use = true;
- return in_use;
+ return !base::win::ScopedHandle(CreateFile(file.value().c_str(),
+ GENERIC_WRITE, 0, NULL,
+ OPEN_EXISTING, 0, 0)).IsValid();
}
-
void InstallerState::GetExistingExeVersions(
std::set<std::string>* existing_versions) const {