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

Side by Side Diff: chrome/installer/mini_installer/decompress.cc

Issue 1133613002: Revert of mini_installer: Change to use _countof rather than base's arraysize macro. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include <windows.h> // NOLINT 5 #include <windows.h> // NOLINT
6 #include <fcntl.h> // for _O_* constants 6 #include <fcntl.h> // for _O_* constants
7 #include <fdi.h> 7 #include <fdi.h>
8 8
9 #include "chrome/installer/mini_installer/decompress.h" 9 #include "chrome/installer/mini_installer/decompress.h"
10 10
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // environment variables set, so we try a couple that *should* always be 183 // environment variables set, so we try a couple that *should* always be
184 // present and fallback to the default Windows install path if all else 184 // present and fallback to the default Windows install path if all else
185 // fails. 185 // fails.
186 // The cabinet.dll should be available on all supported versions of Windows. 186 // The cabinet.dll should be available on all supported versions of Windows.
187 static const wchar_t* const candidate_paths[] = { 187 static const wchar_t* const candidate_paths[] = {
188 L"%WINDIR%\\system32\\cabinet.dll", 188 L"%WINDIR%\\system32\\cabinet.dll",
189 L"%SYSTEMROOT%\\system32\\cabinet.dll", 189 L"%SYSTEMROOT%\\system32\\cabinet.dll",
190 L"C:\\Windows\\system32\\cabinet.dll", 190 L"C:\\Windows\\system32\\cabinet.dll",
191 }; 191 };
192 192
193 static const DWORD kBufferSize = MAX_PATH; 193 wchar_t path[MAX_PATH] = {0};
194 wchar_t path[kBufferSize]; 194 for (int i = 0; i < arraysize(candidate_paths); ++i) {
195 for (const wchar_t* candidate_path : candidate_paths) {
196 path[0] = L'\0'; 195 path[0] = L'\0';
197 DWORD result = ::ExpandEnvironmentStringsW(candidate_path, 196 DWORD result = ::ExpandEnvironmentStringsW(candidate_paths[i],
198 path, kBufferSize); 197 path, arraysize(path));
199 198
200 if (result > 0 && result <= kBufferSize) 199 if (result > 0 && result <= arraysize(path))
201 g_fdi = ::LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); 200 g_fdi = ::LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
202 201
203 if (g_fdi) 202 if (g_fdi)
204 break; 203 break;
205 } 204 }
206 } 205 }
207 206
208 if (g_fdi) { 207 if (g_fdi) {
209 g_FDICreate = 208 g_FDICreate =
210 reinterpret_cast<FDICreateFn>(::GetProcAddress(g_fdi, "FDICreate")); 209 reinterpret_cast<FDICreateFn>(::GetProcAddress(g_fdi, "FDICreate"));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 &Notify, NULL, const_cast<wchar_t*>(destination))) { 252 &Notify, NULL, const_cast<wchar_t*>(destination))) {
254 success = true; 253 success = true;
255 } 254 }
256 g_FDIDestroy(fdi); 255 g_FDIDestroy(fdi);
257 } 256 }
258 257
259 return success; 258 return success;
260 } 259 }
261 260
262 } // namespace mini_installer 261 } // namespace mini_installer
OLDNEW
« no previous file with comments | « chrome/installer/mini_installer/decompress.h ('k') | chrome/installer/mini_installer/mini_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698