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

Inherits:
Object
  • Object
show all
Includes:
Entry, 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



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

def attributes
  @attributes
end

#componentString

Returns Component key.

Returns:

  • (String)

    Component key



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

def component
  @component
end

#creation_timeTime?

Returns Creation time (from CAB).

Returns:

  • (Time, nil)

    Creation time (from CAB)



53
54
55
# File 'lib/omnizip/formats/msi/entry.rb', line 53

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)



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

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)



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

def filename
  @filename
end

#languageString

Returns File language.

Returns:

  • (String)

    File language



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

def language
  @language
end

#last_write_timeTime?

Returns Last write time (from CAB).

Returns:

  • (Time, nil)

    Last write time (from CAB)



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

def last_write_time
  @last_write_time
end

#long_nameString

Returns Long filename (extracted from filename).

Returns:

  • (String)

    Long filename (extracted from filename)



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

def long_name
  @long_name
end

#pathString

Returns Full installation path.

Returns:

  • (String)

    Full installation path



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

def path
  @path
end

#sequenceInteger

Returns Sequence number (maps to Media table).

Returns:

  • (Integer)

    Sequence number (maps to Media table)



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

def sequence
  @sequence
end

#short_nameString

Returns Short filename (8.3 format).

Returns:

  • (String)

    Short filename (8.3 format)



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

def short_name
  @short_name
end

#sizeInteger

Returns File size in bytes.

Returns:

  • (Integer)

    File size in bytes



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

def size
  @size
end

#versionString

Returns File version.

Returns:

  • (String)

    File version



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

def version
  @version
end

Instance Method Details

#attributes_stringString

Get file attributes as string

Returns:

  • (String)

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



89
90
91
92
93
94
95
96
# File 'lib/omnizip/formats/msi/entry.rb', line 89

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)


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

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

#directory?Boolean

Check if entry is a directory

Returns:

  • (Boolean)


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

def directory?
  false
end

#display_nameString

Get display filename (prefers long name)

Returns:

  • (String)


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

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

#entry_directory?Boolean

Returns:

  • (Boolean)


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

def entry_directory? = false

#entry_mtimeObject



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

def entry_mtime = nil

#entry_nameObject



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

def entry_name = path

#entry_sizeObject



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

def entry_size = size

#file?Boolean

Check if entry is a file

Returns:

  • (Boolean)


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

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



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/omnizip/formats/msi/entry.rb', line 105

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)


82
83
84
# File 'lib/omnizip/formats/msi/entry.rb', line 82

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

#windows_pathString

Get path for display (Windows-style backslashes)

Returns:

  • (String)


128
129
130
# File 'lib/omnizip/formats/msi/entry.rb', line 128

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