blob: d2d663047b842480d8b0c8998911f76ffc229114 [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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.commitd7cae122008-07-26 21:49:384
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
[email protected]72c93c702008-08-05 20:00:2613#ifdef OS_MACOSX
14#ifdef __OBJC__
15@class NSBundle;
16#else
17class NSBundle;
18#endif
19#endif
20
initial.commitd7cae122008-07-26 21:49:3821// 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
[email protected]1265917f2008-08-12 17:33:5232 // Creates a FileVersionInfo for the current module. Returns NULL in case
initial.commitd7cae122008-07-26 21:49:3833 // of error. The returned object should be deleted when you are done with it.
[email protected]413dd572008-08-27 20:37:5234 static FileVersionInfo* CreateFileVersionInfoForCurrentModule();
initial.commitd7cae122008-07-26 21:49:3835
36 ~FileVersionInfo();
37
38 // Accessors to the different version properties.
39 // Returns an empty string if the property is not found.
40 std::wstring company_name();
41 std::wstring company_short_name();
42 std::wstring product_name();
43 std::wstring product_short_name();
44 std::wstring internal_name();
45 std::wstring product_version();
46 std::wstring private_build();
47 std::wstring special_build();
48 std::wstring comments();
49 std::wstring original_filename();
50 std::wstring file_description();
51 std::wstring file_version();
52 std::wstring legal_copyright();
53 std::wstring legal_trademarks();
54 std::wstring last_change();
55 bool is_official_build();
56
57 // Lets you access other properties not covered above.
58 bool GetValue(const wchar_t* name, std::wstring* value);
59
60 // Similar to GetValue but returns a wstring (empty string if the property
61 // does not exist).
62 std::wstring GetStringValue(const wchar_t* name);
63
[email protected]72c93c702008-08-05 20:00:2664#ifdef OS_WIN
initial.commitd7cae122008-07-26 21:49:3865 // Get the fixed file info if it exists. Otherwise NULL
66 VS_FIXEDFILEINFO* fixed_file_info() { return fixed_file_info_; }
[email protected]72c93c702008-08-05 20:00:2667#endif
initial.commitd7cae122008-07-26 21:49:3868
69 private:
[email protected]72c93c702008-08-05 20:00:2670#if defined(OS_WIN)
initial.commitd7cae122008-07-26 21:49:3871 FileVersionInfo(void* data, int language, int code_page);
72
73 scoped_ptr_malloc<char> data_;
74 int language_;
75 int code_page_;
76 // This is a pointer into the data_ if it exists. Otherwise NULL.
77 VS_FIXEDFILEINFO* fixed_file_info_;
[email protected]72c93c702008-08-05 20:00:2678#elif defined(OS_MACOSX)
[email protected]1265917f2008-08-12 17:33:5279 explicit FileVersionInfo(NSBundle *bundle);
80 explicit FileVersionInfo(const std::wstring& file_path);
[email protected]72c93c702008-08-05 20:00:2681
[email protected]72c93c702008-08-05 20:00:2682 NSBundle *bundle_;
83#endif
initial.commitd7cae122008-07-26 21:49:3884
85 DISALLOW_EVIL_CONSTRUCTORS(FileVersionInfo);
86};
87
88#endif // BASE_FILE_VERSION_INFO_H__
license.botbf09a502008-08-24 00:55:5589