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

Side by Side Diff: base/file_version_info_win.cc

Issue 4431001: Revert 64960 - Turn on file access checks on Win.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « base/file_util_win.cc ('k') | base/platform_file_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/file_version_info_win.h" 5 #include "base/file_version_info_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_version_info.h" 10 #include "base/file_version_info.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/thread_restrictions.h"
14 13
15 // This has to be last. 14 // This has to be last.
16 #include <strsafe.h> 15 #include <strsafe.h>
17 16
18 FileVersionInfoWin::FileVersionInfoWin(void* data, int language, int code_page) 17 FileVersionInfoWin::FileVersionInfoWin(void* data, int language, int code_page)
19 : language_(language), code_page_(code_page) { 18 : language_(language), code_page_(code_page) {
20 base::ThreadRestrictions::AssertIOAllowed();
21 data_.reset((char*) data); 19 data_.reset((char*) data);
22 fixed_file_info_ = NULL; 20 fixed_file_info_ = NULL;
23 UINT size; 21 UINT size;
24 ::VerQueryValue(data_.get(), L"\\", (LPVOID*)&fixed_file_info_, &size); 22 ::VerQueryValue(data_.get(), L"\\", (LPVOID*)&fixed_file_info_, &size);
25 } 23 }
26 24
27 FileVersionInfoWin::~FileVersionInfoWin() { 25 FileVersionInfoWin::~FileVersionInfoWin() {
28 DCHECK(data_.get()); 26 DCHECK(data_.get());
29 } 27 }
30 28
31 typedef struct { 29 typedef struct {
32 WORD language; 30 WORD language;
33 WORD code_page; 31 WORD code_page;
34 } LanguageAndCodePage; 32 } LanguageAndCodePage;
35 33
36 // static 34 // static
37 FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() { 35 FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() {
38 FilePath app_path; 36 FilePath app_path;
39 if (!PathService::Get(base::FILE_MODULE, &app_path)) 37 if (!PathService::Get(base::FILE_MODULE, &app_path))
40 return NULL; 38 return NULL;
41 39
42 return CreateFileVersionInfo(app_path); 40 return CreateFileVersionInfo(app_path);
43 } 41 }
44 42
45 // static 43 // static
46 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( 44 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo(
47 const FilePath& file_path) { 45 const FilePath& file_path) {
48 base::ThreadRestrictions::AssertIOAllowed();
49
50 DWORD dummy; 46 DWORD dummy;
51 const wchar_t* path = file_path.value().c_str(); 47 const wchar_t* path = file_path.value().c_str();
52 DWORD length = ::GetFileVersionInfoSize(path, &dummy); 48 DWORD length = ::GetFileVersionInfoSize(path, &dummy);
53 if (length == 0) 49 if (length == 0)
54 return NULL; 50 return NULL;
55 51
56 void* data = calloc(length, 1); 52 void* data = calloc(length, 1);
57 if (!data) 53 if (!data)
58 return NULL; 54 return NULL;
59 55
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 return false; 179 return false;
184 } 180 }
185 181
186 std::wstring FileVersionInfoWin::GetStringValue(const wchar_t* name) { 182 std::wstring FileVersionInfoWin::GetStringValue(const wchar_t* name) {
187 std::wstring str; 183 std::wstring str;
188 if (GetValue(name, &str)) 184 if (GetValue(name, &str))
189 return str; 185 return str;
190 else 186 else
191 return L""; 187 return L"";
192 } 188 }
OLDNEW
« no previous file with comments | « base/file_util_win.cc ('k') | base/platform_file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698