summaryrefslogtreecommitdiffstats
path: root/chrome/installer/setup/setup_util.cc
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 19:44:07 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 19:44:07 +0000
commitec37d38793379facce6e10bafa9b4456efcdd12f (patch)
treeed1adb3bf1c29dc8a96a9fc8da3a1248908793ac /chrome/installer/setup/setup_util.cc
parent731980c04db87643c41d6f8d6f594de1cf7b725d (diff)
downloadchromium_src-ec37d38793379facce6e10bafa9b4456efcdd12f.zip
chromium_src-ec37d38793379facce6e10bafa9b4456efcdd12f.tar.gz
chromium_src-ec37d38793379facce6e10bafa9b4456efcdd12f.tar.bz2
Renamed installer_unittests to util_unittests and added setup_unitests project with only one unit test for now.
BUG=12849 TEST=none Review URL: http://codereview.chromium.org/118247 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17758 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/setup/setup_util.cc')
-rw-r--r--chrome/installer/setup/setup_util.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc
new file mode 100644
index 0000000..7356ecf
--- /dev/null
+++ b/chrome/installer/setup/setup_util.cc
@@ -0,0 +1,36 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// This file declares util functions for setup project.
+
+#include "chrome/installer/setup/setup_util.h"
+
+#include "base/file_util.h"
+#include "base/logging.h"
+
+installer::Version* setup_util::GetVersionFromDir(
+ const std::wstring& chrome_path) {
+ LOG(INFO) << "Looking for Chrome version folder under " << chrome_path;
+ std::wstring root_path(chrome_path);
+ file_util::AppendToPath(&root_path, L"*");
+
+ WIN32_FIND_DATA find_data;
+ HANDLE file_handle = FindFirstFile(root_path.c_str(), &find_data);
+ BOOL ret = TRUE;
+ installer::Version *version = NULL;
+ // Here we are assuming that the installer we have is really valid so there
+ // can not be two version directories. We exit as soon as we find a valid
+ // version directory.
+ while (ret) {
+ if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ LOG(INFO) << "directory found: " << find_data.cFileName;
+ version = installer::Version::GetVersionFromString(find_data.cFileName);
+ if (version) break;
+ }
+ ret = FindNextFile(file_handle, &find_data);
+ }
+ FindClose(file_handle);
+
+ return version;
+}