file_version_info_win.h (1631B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 // This is a partial implementation of Chromium's source file 8 // base/file_version_info_win.h. 9 10 #ifndef BASE_FILE_VERSION_INFO_WIN_H_ 11 #define BASE_FILE_VERSION_INFO_WIN_H_ 12 13 #include <memory> 14 #include <minwindef.h> 15 #include <vector> 16 17 #include "base/version.h" 18 19 #include "mozilla/Assertions.h" 20 21 struct tagVS_FIXEDFILEINFO; 22 typedef tagVS_FIXEDFILEINFO VS_FIXEDFILEINFO; 23 24 namespace base { 25 class FilePath; 26 } 27 28 class FileVersionInfoWin { 29 public: 30 FileVersionInfoWin(const FileVersionInfoWin&) = delete; 31 FileVersionInfoWin& operator=(const FileVersionInfoWin&) = delete; 32 33 static std::unique_ptr<FileVersionInfoWin> CreateFileVersionInfoWin( 34 const base::FilePath& file_path); 35 36 // Get file version number in dotted version format. 37 base::Version GetFileVersion() const; 38 39 private: 40 // |data| is a VS_VERSION_INFO resource. |language| and |code_page| are 41 // extracted from the \VarFileInfo\Translation value of |data|. 42 FileVersionInfoWin(std::vector<uint8_t>&& data, 43 WORD language, 44 WORD code_page); 45 46 const std::vector<uint8_t> owned_data_; 47 const void* const data_; 48 const WORD language_; 49 const WORD code_page_; 50 51 // This is a reference for a portion of |data_|. 52 const VS_FIXEDFILEINFO& fixed_file_info_; 53 }; 54 55 #endif // BASE_FILE_VERSION_INFO_WIN_H_