Class: Exerb::Resource::VersionInfo

Inherits:
Base
  • Object
show all
Defined in:
lib/exerb/resource/version_info.rb

Overview

#

Defined Under Namespace

Classes: BlockBase, BlockType0, BlockType1, BlockType1String

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#size

Constructor Details

#initializeVersionInfo

Returns a new instance of VersionInfo



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/exerb/resource/version_info.rb', line 23

def initialize
  @file_version_number    = 0
  @product_version_number = 0
  @comments               = ""
  @company_name           = ""
  @legal_copyright        = ""
  @legal_trademarks       = ""
  @file_version           = ""
  @product_version        = ""
  @product_name           = ""
  @file_description       = ""
  @internal_name          = ""
  @original_filename      = ""
  @private_build          = ""
  @special_build          = ""

  @is_dll = false
end

Instance Attribute Details

#commentsObject

Returns the value of attribute comments



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def comments
  @comments
end

#company_nameObject

Returns the value of attribute company_name



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def company_name
  @company_name
end

#file_descriptionObject

Returns the value of attribute file_description



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def file_description
  @file_description
end

#file_versionObject

Returns the value of attribute file_version



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def file_version
  @file_version
end

#file_version_numberObject

Returns the value of attribute file_version_number



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def file_version_number
  @file_version_number
end

#internal_nameObject

Returns the value of attribute internal_name



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def internal_name
  @internal_name
end

#is_dllObject

Returns the value of attribute is_dll



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def is_dll
  @is_dll
end

Returns the value of attribute legal_copyright



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def legal_copyright
  @legal_copyright
end

Returns the value of attribute legal_trademarks



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def legal_trademarks
  @legal_trademarks
end

#original_filenameObject

Returns the value of attribute original_filename



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def original_filename
  @original_filename
end

#private_buildObject

Returns the value of attribute private_build



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def private_build
  @private_build
end

#product_nameObject

Returns the value of attribute product_name



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def product_name
  @product_name
end

#product_versionObject

Returns the value of attribute product_version



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def product_version
  @product_version
end

#product_version_numberObject

Returns the value of attribute product_version_number



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def product_version_number
  @product_version_number
end

#special_buildObject

Returns the value of attribute special_build



42
43
44
# File 'lib/exerb/resource/version_info.rb', line 42

def special_build
  @special_build
end

Class Method Details

.make_version(n1, n2, n3, n4) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/exerb/resource/version_info.rb', line 44

def self.make_version(n1, n2, n3, n4)
  version  = (n1 & 0xFFFF) << 48
  version |= (n2 & 0xFFFF) << 32
  version |= (n3 & 0xFFFF) << 16
  version |= (n4 & 0xFFFF)

  return version
end

Instance Method Details

#packObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/exerb/resource/version_info.rb', line 53

def pack
  vsffi = Exerb::Win32::Struct::VsFixedFileInfo.new
  vsffi.signature          = Exerb::Win32::Const::VS_FFI_SIGNATURE
  vsffi.struct_version     = Exerb::Win32::Const::VS_FFI_STRUCVERSION
  vsffi.file_version_ms    = @file_version_number >> 32
  vsffi.file_version_ls    = @file_version_number & 0xFFFFFFFF
  vsffi.product_version_ms = @product_version_number >> 32
  vsffi.product_version_ls = @product_version_number & 0xFFFFFFFF
  vsffi.file_flags_mask    = Exerb::Win32::Const::VS_FFI_FILEFLAGSMASK
  vsffi.file_flags         = 0x00000000
  vsffi.file_os            = Exerb::Win32::Const::VOS_NT_WINDOWS32
  vsffi.file_type          = (@is_dll ? Exerb::Win32::Const::VFT_DLL : Exerb::Win32::Const::VFT_APP)
  vsffi.file_subtype       = Exerb::Win32::Const::VFT2_UNKNOWN
  vsffi.file_date_ms       = 0x00000000
  vsffi.file_date_ls       = 0x00000000

  block = BlockType0.new('VS_VERSION_INFO', vsffi.pack) { |vvi|
    vvi << BlockType1.new('StringFileInfo') { |sfi|
      # Language:Neutral CodePage:Unicode
      sfi << BlockType1.new('000004b0') { |neutral|
        neutral << BlockType1String.new('Comments',         @comments)
        neutral << BlockType1String.new('CompanyName',      @company_name)
        neutral << BlockType1String.new('LegalCopyright',   @legal_copyright)
        neutral << BlockType1String.new('LegalTrademarks',  @legal_trademarks)
        neutral << BlockType1String.new('FileVersion',      @file_version)
        neutral << BlockType1String.new('ProductVersion',   @product_version)
        neutral << BlockType1String.new('ProductName',      @product_name)
        neutral << BlockType1String.new('FileDescription',  @file_description)
        neutral << BlockType1String.new('InternalName',     @internal_name)
        neutral << BlockType1String.new('OriginalFilename', @original_filename)
        neutral << BlockType1String.new('PrivateBuild',     @private_build)
        neutral << BlockType1String.new('SpecialBuild',     @special_build)
      }
    }
    vvi << BlockType1.new('VarFileInfo') { |vfi|
      vfi << BlockType0.new('Translation', [0x04B00000].pack('L'))
    }
  }

  return block.pack
end