Class: LibMsPack::MsCab::MsCabdFile

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/libmspack/mscab.rb

Overview

A structure which represents a single file in a cabinet or cabinet set.

Instance Method Summary collapse

Instance Method Details

#attribsFixnum

File attributes.

The following attributes are defined:

  • MSCAB_ATTRIB_RDONLY indicates the file is write protected.
  • MSCAB_ATTRIB_HIDDEN indicates the file is hidden.
  • MSCAB_ATTRIB_SYSTEM indicates the file is a operating system file.
  • MSCAB_ATTRIB_ARCH indicates the file is "archived".
  • MSCAB_ATTRIB_EXEC indicates the file is an executable program.
  • MSCAB_ATTRIB_UTF_NAME indicates the filename is in UTF8 format rather than ISO-8859-1.

Returns:

  • (Fixnum)


174
175
176
# File 'lib/libmspack/mscab.rb', line 174

def attribs
    self[:attribs]
end

#datetimeTime

File's last modified datetime.

Returns:

  • (Time)


181
182
183
# File 'lib/libmspack/mscab.rb', line 181

def datetime
    Time.gm(self[:date_y], self[:date_m], self[:date_d], self[:time_h], self[:time_m], self[:time_s])
end

#filenameString

The filename of the file.

String of up to 255 bytes in length, it may be in either ISO-8859-1 or UTF8 format, depending on the file attributes.

Returns:

  • (String)


138
139
140
# File 'lib/libmspack/mscab.rb', line 138

def filename
    self[:filename]
end

#folderMsCabdFolder?

Folder that contains this file.

Returns:



188
189
190
191
# File 'lib/libmspack/mscab.rb', line 188

def folder
    return nil if self[:folder].pointer.address.zero?
    self[:folder]
end

#getFilenameString

The filename of the file.

Returns:

  • (String)


145
146
147
148
149
150
151
152
153
# File 'lib/libmspack/mscab.rb', line 145

def getFilename
    str = filename.dup
    if (attribs & Constants::MSCAB_ATTRIB_UTF_NAME) == Constants::MSCAB_ATTRIB_UTF_NAME
        str.force_encoding(Encoding::UTF_8)
    else
        str.force_encoding(Encoding::ISO_8859_1)
    end
    str
end

#lengthFixnum

The uncompressed length of the file, in bytes.

Returns:

  • (Fixnum)


158
159
160
# File 'lib/libmspack/mscab.rb', line 158

def length
    self[:length]
end

#nextMsCabdFile?

The next file in the cabinet or cabinet set, or nil if this is the final file.

Returns:



128
129
130
131
# File 'lib/libmspack/mscab.rb', line 128

def next
    return nil if self[:next].pointer.address.zero?
    self[:next]
end

#offsetFixnum

The uncompressed offset of this file in its folder.

Returns:

  • (Fixnum)


196
197
198
# File 'lib/libmspack/mscab.rb', line 196

def offset
    self[:offset]
end