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

Unified Diff: chrome/installer/setup/setup_util.cc

Issue 118247: Add project for setup unittests (Closed)
Patch Set: fix tab char Created 11 years, 7 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
Index: chrome/installer/setup/setup_util.cc
diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7356ecffa329cefe4f9d5e37a7c7b04a4434e56a
--- /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;
+}

Powered by Google App Engine
This is Rietveld 408576698