OLD | NEW |
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 #ifndef BASE_FILE_VERSION_INFO_H__ | 5 #ifndef BASE_FILE_VERSION_INFO_H__ |
6 #define BASE_FILE_VERSION_INFO_H__ | 6 #define BASE_FILE_VERSION_INFO_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "build/build_config.h" |
11 #include "base/scoped_ptr.h" | |
12 | |
13 #if defined(OS_WIN) | |
14 struct tagVS_FIXEDFILEINFO; | |
15 typedef tagVS_FIXEDFILEINFO VS_FIXEDFILEINFO; | |
16 #elif defined(OS_MACOSX) | |
17 #ifdef __OBJC__ | |
18 @class NSBundle; | |
19 #else | |
20 class NSBundle; | |
21 #endif | |
22 #endif | |
23 | 11 |
24 class FilePath; | 12 class FilePath; |
25 | 13 |
26 // Provides a way to access the version information for a file. | 14 // Provides an interface for accessing the version information for a file. |
27 // This is the information you access when you select a file in the Windows | 15 // This is the information you access when you select a file in the Windows |
28 // explorer, right-click select Properties, then click the Version tab. | 16 // explorer, right-click select Properties, then click the Version tab. |
29 | 17 |
30 class FileVersionInfo { | 18 class FileVersionInfo { |
31 public: | 19 public: |
| 20 #if defined(OS_WIN) || defined(OS_MACOSX) |
32 // Creates a FileVersionInfo for the specified path. Returns NULL if something | 21 // Creates a FileVersionInfo for the specified path. Returns NULL if something |
33 // goes wrong (typically the file does not exit or cannot be opened). The | 22 // goes wrong (typically the file does not exit or cannot be opened). The |
34 // returned object should be deleted when you are done with it. | 23 // returned object should be deleted when you are done with it. |
35 static FileVersionInfo* CreateFileVersionInfo(const FilePath& file_path); | 24 static FileVersionInfo* CreateFileVersionInfo(const FilePath& file_path); |
36 // This version, taking a wstring, is deprecated and only kept around | 25 // This version, taking a wstring, is deprecated and only kept around |
37 // until we can fix all callers. | 26 // until we can fix all callers. |
38 static FileVersionInfo* CreateFileVersionInfo(const std::wstring& file_path); | 27 static FileVersionInfo* CreateFileVersionInfo(const std::wstring& file_path); |
| 28 #endif |
39 | 29 |
40 // Creates a FileVersionInfo for the current module. Returns NULL in case | 30 // Creates a FileVersionInfo for the current module. Returns NULL in case |
41 // of error. The returned object should be deleted when you are done with it. | 31 // of error. The returned object should be deleted when you are done with it. |
42 static FileVersionInfo* CreateFileVersionInfoForCurrentModule(); | 32 static FileVersionInfo* CreateFileVersionInfoForCurrentModule(); |
43 | 33 |
44 ~FileVersionInfo(); | |
45 | |
46 // Accessors to the different version properties. | 34 // Accessors to the different version properties. |
47 // Returns an empty string if the property is not found. | 35 // Returns an empty string if the property is not found. |
48 std::wstring company_name(); | 36 virtual std::wstring company_name() = 0; |
49 std::wstring company_short_name(); | 37 virtual std::wstring company_short_name() = 0; |
50 std::wstring product_name(); | 38 virtual std::wstring product_name() = 0; |
51 std::wstring product_short_name(); | 39 virtual std::wstring product_short_name() = 0; |
52 std::wstring internal_name(); | 40 virtual std::wstring internal_name() = 0; |
53 std::wstring product_version(); | 41 virtual std::wstring product_version() = 0; |
54 std::wstring private_build(); | 42 virtual std::wstring private_build() = 0; |
55 std::wstring special_build(); | 43 virtual std::wstring special_build() = 0; |
56 std::wstring comments(); | 44 virtual std::wstring comments() = 0; |
57 std::wstring original_filename(); | 45 virtual std::wstring original_filename() = 0; |
58 std::wstring file_description(); | 46 virtual std::wstring file_description() = 0; |
59 std::wstring file_version(); | 47 virtual std::wstring file_version() = 0; |
60 std::wstring legal_copyright(); | 48 virtual std::wstring legal_copyright() = 0; |
61 std::wstring legal_trademarks(); | 49 virtual std::wstring legal_trademarks() = 0; |
62 std::wstring last_change(); | 50 virtual std::wstring last_change() = 0; |
63 bool is_official_build(); | 51 virtual bool is_official_build() = 0; |
64 | |
65 // Lets you access other properties not covered above. | |
66 bool GetValue(const wchar_t* name, std::wstring* value); | |
67 | |
68 // Similar to GetValue but returns a wstring (empty string if the property | |
69 // does not exist). | |
70 std::wstring GetStringValue(const wchar_t* name); | |
71 | |
72 #ifdef OS_WIN | |
73 // Get the fixed file info if it exists. Otherwise NULL | |
74 VS_FIXEDFILEINFO* fixed_file_info() { return fixed_file_info_; } | |
75 #endif | |
76 | |
77 private: | |
78 #if defined(OS_WIN) | |
79 FileVersionInfo(void* data, int language, int code_page); | |
80 | |
81 scoped_ptr_malloc<char> data_; | |
82 int language_; | |
83 int code_page_; | |
84 // This is a pointer into the data_ if it exists. Otherwise NULL. | |
85 VS_FIXEDFILEINFO* fixed_file_info_; | |
86 #elif defined(OS_MACOSX) | |
87 explicit FileVersionInfo(NSBundle *bundle); | |
88 | |
89 NSBundle *bundle_; | |
90 #elif defined(OS_POSIX) | |
91 FileVersionInfo(); | |
92 #endif | |
93 | |
94 DISALLOW_EVIL_CONSTRUCTORS(FileVersionInfo); | |
95 }; | 52 }; |
96 | 53 |
97 #endif // BASE_FILE_VERSION_INFO_H__ | 54 #endif // BASE_FILE_VERSION_INFO_H__ |
OLD | NEW |