Class: Omnizip::Formats::Msi::Entry
- Inherits:
-
Object
- Object
- Omnizip::Formats::Msi::Entry
- 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
-
#attributes ⇒ Integer
File attributes.
-
#component ⇒ String
Component key.
-
#creation_time ⇒ Time?
Creation time (from CAB).
-
#file_key ⇒ String
File key (primary key from File table).
-
#filename ⇒ String
Filename from File table (may be "short|long" format).
-
#language ⇒ String
File language.
-
#last_write_time ⇒ Time?
Last write time (from CAB).
-
#long_name ⇒ String
Long filename (extracted from filename).
-
#path ⇒ String
Full installation path.
-
#sequence ⇒ Integer
Sequence number (maps to Media table).
-
#short_name ⇒ String
Short filename (8.3 format).
-
#size ⇒ Integer
File size in bytes.
-
#version ⇒ String
File version.
Instance Method Summary collapse
-
#attributes_string ⇒ String
Get file attributes as string.
-
#compressed? ⇒ Boolean
Check if file is compressed.
-
#directory? ⇒ Boolean
Check if entry is a directory.
-
#display_name ⇒ String
Get display filename (prefers long name).
-
#file? ⇒ Boolean
Check if entry is a file.
-
#parse_filename(filename) ⇒ Object
Parse filename field.
-
#vital? ⇒ Boolean
Check if file is vital (must be present for installation).
-
#windows_path ⇒ String
Get path for display (Windows-style backslashes).
Methods included from Constants
Instance Attribute Details
#attributes ⇒ Integer
Returns File attributes.
44 45 46 |
# File 'lib/omnizip/formats/msi/entry.rb', line 44 def attributes @attributes end |
#component ⇒ String
Returns Component key.
20 21 22 |
# File 'lib/omnizip/formats/msi/entry.rb', line 20 def component @component end |
#creation_time ⇒ Time?
Returns Creation time (from CAB).
47 48 49 |
# File 'lib/omnizip/formats/msi/entry.rb', line 47 def creation_time @creation_time end |
#file_key ⇒ String
Returns 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 |
#filename ⇒ String
Returns 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 |
#language ⇒ String
Returns File language.
41 42 43 |
# File 'lib/omnizip/formats/msi/entry.rb', line 41 def language @language end |
#last_write_time ⇒ Time?
Returns 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_name ⇒ String
Returns Long filename (extracted from filename).
26 27 28 |
# File 'lib/omnizip/formats/msi/entry.rb', line 26 def long_name @long_name end |
#path ⇒ String
Returns Full installation path.
14 15 16 |
# File 'lib/omnizip/formats/msi/entry.rb', line 14 def path @path end |
#sequence ⇒ Integer
Returns Sequence number (maps to Media table).
35 36 37 |
# File 'lib/omnizip/formats/msi/entry.rb', line 35 def sequence @sequence end |
#short_name ⇒ String
Returns Short filename (8.3 format).
29 30 31 |
# File 'lib/omnizip/formats/msi/entry.rb', line 29 def short_name @short_name end |
#size ⇒ Integer
Returns File size in bytes.
32 33 34 |
# File 'lib/omnizip/formats/msi/entry.rb', line 32 def size @size end |
#version ⇒ String
Returns File version.
38 39 40 |
# File 'lib/omnizip/formats/msi/entry.rb', line 38 def version @version end |
Instance Method Details
#attributes_string ⇒ String
Get file attributes as string
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
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
55 56 57 |
# File 'lib/omnizip/formats/msi/entry.rb', line 55 def directory? false end |
#display_name ⇒ String
Get display filename (prefers long name)
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
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
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)
76 77 78 |
# File 'lib/omnizip/formats/msi/entry.rb', line 76 def vital? @attributes&.anybits?(FILE_ATTR_VITAL) end |
#windows_path ⇒ String
Get path for display (Windows-style backslashes)
122 123 124 |
# File 'lib/omnizip/formats/msi/entry.rb', line 122 def windows_path @path&.gsub("/", "\\") end |