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