blob: 7d50eac53410b47dbe8ecdb957b89b0eb61f14cc [file] [log] [blame]
license.botf003cfe2008-08-24 09:55:55 +09001// 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.commit3f4a7322008-07-27 06:49:38 +09004
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.com9ea1e862008-08-06 05:00:26 +090013#ifdef OS_MACOSX
14#ifdef __OBJC__
15@class NSBundle;
16#else
17class NSBundle;
18#endif
19#endif
20
initial.commit3f4a7322008-07-27 06:49:38 +090021// 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
25class 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.coma3ff2752008-08-13 02:33:52 +090032 // Creates a FileVersionInfo for the current module. Returns NULL in case
initial.commit3f4a7322008-07-27 06:49:38 +090033 // 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.com9ea1e862008-08-06 05:00:26 +090065#ifdef OS_WIN
initial.commit3f4a7322008-07-27 06:49:38 +090066 // Get the fixed file info if it exists. Otherwise NULL
67 VS_FIXEDFILEINFO* fixed_file_info() { return fixed_file_info_; }
paulg@google.com9ea1e862008-08-06 05:00:26 +090068#endif
initial.commit3f4a7322008-07-27 06:49:38 +090069
70 private:
paulg@google.com9ea1e862008-08-06 05:00:26 +090071#if defined(OS_WIN)
initial.commit3f4a7322008-07-27 06:49:38 +090072 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.com9ea1e862008-08-06 05:00:26 +090079#elif defined(OS_MACOSX)
erikkay@google.coma3ff2752008-08-13 02:33:52 +090080 explicit FileVersionInfo(NSBundle *bundle);
81 explicit FileVersionInfo(const std::wstring& file_path);
paulg@google.com9ea1e862008-08-06 05:00:26 +090082
paulg@google.com9ea1e862008-08-06 05:00:26 +090083 NSBundle *bundle_;
84#endif
initial.commit3f4a7322008-07-27 06:49:38 +090085
86 DISALLOW_EVIL_CONSTRUCTORS(FileVersionInfo);
87};
88
89#endif // BASE_FILE_VERSION_INFO_H__
license.botf003cfe2008-08-24 09:55:55 +090090