Class: Omnizip::Formats::Msi::Entry

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/omnizip/formats/msi/entry.rb

Overview

MSI File Entry

Represents a single file within an MSI package. File information is assembled from File, Component, and Directory tables.

Constant Summary

Constants included from Constants

Constants::BINARY_TYPE, Constants::CATEGORY_BINARY, Constants::CATEGORY_CABINET, Constants::CATEGORY_CONDITION, Constants::CATEGORY_DEFAULT, Constants::CATEGORY_DOUBLE, Constants::CATEGORY_FILENAME, Constants::CATEGORY_GUID, Constants::CATEGORY_IDENTIFIER, Constants::CATEGORY_LANGUAGE, Constants::CATEGORY_LOWERCASE, Constants::CATEGORY_PATH, Constants::CATEGORY_SHORTCUT, Constants::CATEGORY_TEMPLATE, Constants::CATEGORY_TEXT, Constants::CATEGORY_UPPERCASE, Constants::CATEGORY_VERSION, Constants::COLUMNS_STREAM, Constants::COMPONENT_TABLE, Constants::COMP_ATTR_64BIT, Constants::COMP_ATTR_DISABLE_REGISTRY, Constants::COMP_ATTR_LOCAL_ONLY, Constants::COMP_ATTR_NEVER_OVERWRITE, Constants::COMP_ATTR_ODBC, Constants::COMP_ATTR_OPTIONAL, Constants::COMP_ATTR_PERMANENT, Constants::COMP_ATTR_REGISTRY_KEY_PATH, Constants::COMP_ATTR_SHARED, Constants::COMP_ATTR_SHARED_DLL, Constants::COMP_ATTR_SOURCE_ONLY, Constants::COMP_ATTR_TRANSITIVE, Constants::COMP_ATTR_UNINSTALL_ON_SUPERSEDE, Constants::DIRECTORY_TABLE, Constants::EMBEDDED_CAB_PREFIX, Constants::FILE_ATTR_CHECKSUM, Constants::FILE_ATTR_COMPRESSED, Constants::FILE_ATTR_HIDDEN, Constants::FILE_ATTR_NONCOMPRESSED, Constants::FILE_ATTR_PATCHADDED, Constants::FILE_ATTR_READONLY, Constants::FILE_ATTR_SYSTEM, Constants::FILE_ATTR_VITAL, Constants::FILE_TABLE, Constants::INT16_TYPE, Constants::INT32_TYPE, Constants::MEDIA_TABLE, Constants::OBJECT_TYPE, Constants::PROGRAM_FILES, Constants::PROGRAM_FILES_X64, Constants::SOURCE_DIR, Constants::STREAMS_TABLE, Constants::STRING_DATA_STREAM, Constants::STRING_POOL_STREAM, Constants::STRING_TYPE, Constants::SYSTEM_FOLDER, Constants::SYSTEM_X64_FOLDER, Constants::TABLES_STREAM, Constants::TARGET_DIR, Constants::WINDOWS_FOLDER

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Constants

decode_stream_name

Instance Attribute Details

#attributesInteger

Returns File attributes.

Returns:

  • (Integer)

    File attributes



44
45
46
# File 'lib/omnizip/formats/msi/entry.rb', line 44

def attributes
  @attributes
end

#componentString

Returns Component key.

Returns:

  • (String)

    Component key



20
21
22
# File 'lib/omnizip/formats/msi/entry.rb', line 20

def component
  @component
end

#creation_timeTime?

Returns Creation time (from CAB).

Returns:

  • (Time, nil)

    Creation time (from CAB)



47
48
49
# File 'lib/omnizip/formats/msi/entry.rb', line 47

def creation_time
  @creation_time
end

#file_keyString

Returns File key (primary key from File table).

Returns:

  • (String)

    File key (primary key from File table)



17
18
19
# File 'lib/omnizip/formats/msi/entry.rb', line 17

def file_key
  @file_key
end

#filenameString

Returns Filename from File table (may be "short|long" format).

Returns:

  • (String)

    Filename from File table (may be "short|long" format)



23
24
25
# File 'lib/omnizip/formats/msi/entry.rb', line 23

def filename
  @filename
end

#languageString

Returns File language.

Returns:

  • (String)

    File language



41
42
43
# File 'lib/omnizip/formats/msi/entry.rb', line 41

def language
  @language
end

#last_write_timeTime?

Returns Last write time (from CAB).

Returns:

  • (Time, nil)

    Last write time (from CAB)



50
51
52
# File 'lib/omnizip/formats/msi/entry.rb', line 50

def last_write_time
  @last_write_time
end

#long_nameString

Returns Long filename (extracted from filename).

Returns:

  • (String)

    Long filename (extracted from filename)



26
27
28
# File 'lib/omnizip/formats/msi/entry.rb', line 26

def long_name
  @long_name
end

#pathString

Returns Full installation path.

Returns:

  • (String)

    Full installation path



14
15
16
# File 'lib/omnizip/formats/msi/entry.rb', line 14

def path
  @path
end

#sequenceInteger

Returns Sequence number (maps to Media table).

Returns:

  • (Integer)

    Sequence number (maps to Media table)



35
36
37
# File 'lib/omnizip/formats/msi/entry.rb', line 35

def sequence
  @sequence
end

#short_nameString

Returns Short filename (8.3 format).

Returns:

  • (String)

    Short filename (8.3 format)



29
30
31
# File 'lib/omnizip/formats/msi/entry.rb', line 29

def short_name
  @short_name
end

#sizeInteger

Returns File size in bytes.

Returns:

  • (Integer)

    File size in bytes



32
33
34
# File 'lib/omnizip/formats/msi/entry.rb', line 32

def size
  @size
end

#versionString

Returns File version.

Returns:

  • (String)

    File version



38
39
40
# File 'lib/omnizip/formats/msi/entry.rb', line 38

def version
  @version
end

Instance Method Details

#attributes_stringString

Get file attributes as string

Returns:

  • (String)

    Attributes string (e.g., "Archive")



83
84
85
86
87
88
89
90
# File 'lib/omnizip/formats/msi/entry.rb', line 83

def attributes_string
  attrs = []
  attrs << "Archive"
  attrs << "ReadOnly" if @attributes&.anybits?(FILE_ATTR_READONLY)
  attrs << "Hidden" if @attributes&.anybits?(FILE_ATTR_HIDDEN)
  attrs << "System" if @attributes&.anybits?(FILE_ATTR_SYSTEM)
  attrs.join(", ")
end

#compressed?Boolean

Check if file is compressed

Returns:

  • (Boolean)


69
70
71
# File 'lib/omnizip/formats/msi/entry.rb', line 69

def compressed?
  @attributes&.anybits?(FILE_ATTR_COMPRESSED)
end

#directory?Boolean

Check if entry is a directory

Returns:

  • (Boolean)


55
56
57
# File 'lib/omnizip/formats/msi/entry.rb', line 55

def directory?
  false
end

#display_nameString

Get display filename (prefers long name)

Returns:

  • (String)


115
116
117
# File 'lib/omnizip/formats/msi/entry.rb', line 115

def display_name
  @long_name || @short_name || @filename || ""
end

#file?Boolean

Check if entry is a file

Returns:

  • (Boolean)


62
63
64
# File 'lib/omnizip/formats/msi/entry.rb', line 62

def file?
  true
end

#parse_filename(filename) ⇒ Object

Parse filename field

MSI File.Filename can be:

  • "short|long" - both short and long names
  • "name" - just the name

Parameters:

  • filename (String)

    Raw filename from File table



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/omnizip/formats/msi/entry.rb', line 99

def parse_filename(filename)
  @filename = filename

  if filename&.include?("|")
    parts = filename.split("|", 2)
    @short_name = parts[0]
    @long_name = parts[1]
  else
    @long_name = filename
    @short_name = nil
  end
end

#vital?Boolean

Check if file is vital (must be present for installation)

Returns:

  • (Boolean)


76
77
78
# File 'lib/omnizip/formats/msi/entry.rb', line 76

def vital?
  @attributes&.anybits?(FILE_ATTR_VITAL)
end

#windows_pathString

Get path for display (Windows-style backslashes)

Returns:

  • (String)


122
123
124
# File 'lib/omnizip/formats/msi/entry.rb', line 122

def windows_path
  @path&.gsub("/", "\\")
end