OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file declares util functions for setup project. | 5 // This file declares util functions for setup project. |
6 | 6 |
7 #include "chrome/installer/setup/setup_util.h" | 7 #include "chrome/installer/setup/setup_util.h" |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 | 55 |
56 Version* GetMaxVersionFromArchiveDir(const FilePath& chrome_path) { | 56 Version* GetMaxVersionFromArchiveDir(const FilePath& chrome_path) { |
57 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); | 57 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); |
58 Version* version = NULL; | 58 Version* version = NULL; |
59 file_util::FileEnumerator version_enum(chrome_path, false, | 59 file_util::FileEnumerator version_enum(chrome_path, false, |
60 file_util::FileEnumerator::DIRECTORIES); | 60 file_util::FileEnumerator::DIRECTORIES); |
61 // TODO(tommi): The version directory really should match the version of | 61 // TODO(tommi): The version directory really should match the version of |
62 // setup.exe. To begin with, we should at least DCHECK that that's true. | 62 // setup.exe. To begin with, we should at least DCHECK that that's true. |
63 | 63 |
64 scoped_ptr<Version> max_version(Version::GetVersionFromString("0.0.0.0")); | 64 scoped_ptr<Version> max_version(new Version("0.0.0.0")); |
65 bool version_found = false; | 65 bool version_found = false; |
66 | 66 |
67 while (!version_enum.Next().empty()) { | 67 while (!version_enum.Next().empty()) { |
68 file_util::FileEnumerator::FindInfo find_data = {0}; | 68 file_util::FileEnumerator::FindInfo find_data = {0}; |
69 version_enum.GetFindInfo(&find_data); | 69 version_enum.GetFindInfo(&find_data); |
70 VLOG(1) << "directory found: " << find_data.cFileName; | 70 VLOG(1) << "directory found: " << find_data.cFileName; |
71 | 71 |
72 scoped_ptr<Version> found_version( | 72 scoped_ptr<Version> found_version( |
73 Version::GetVersionFromString(WideToASCII(find_data.cFileName))); | 73 new Version(WideToASCII(find_data.cFileName))); |
74 if (found_version.get() != NULL && | 74 if (found_version->IsValid() && |
75 found_version->CompareTo(*max_version.get()) > 0) { | 75 found_version->CompareTo(*max_version.get()) > 0) { |
76 max_version.reset(found_version.release()); | 76 max_version.reset(found_version.release()); |
77 version_found = true; | 77 version_found = true; |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 return (version_found ? max_version.release() : NULL); | 81 return (version_found ? max_version.release() : NULL); |
82 } | 82 } |
83 | 83 |
84 bool DeleteFileFromTempProcess(const FilePath& path, | 84 bool DeleteFileFromTempProcess(const FilePath& path, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 ::TerminateProcess(pi.hProcess, ~0); | 132 ::TerminateProcess(pi.hProcess, ~0); |
133 } | 133 } |
134 ::CloseHandle(pi.hThread); | 134 ::CloseHandle(pi.hThread); |
135 ::CloseHandle(pi.hProcess); | 135 ::CloseHandle(pi.hProcess); |
136 } | 136 } |
137 | 137 |
138 return ok != FALSE; | 138 return ok != FALSE; |
139 } | 139 } |
140 | 140 |
141 } // namespace installer | 141 } // namespace installer |
OLD | NEW |