Class: Cabriolet::Models::Cabinet

Inherits:
Object
  • Object
show all
Defined in:
lib/cabriolet/models/cabinet.rb

Overview

Cabinet represents a CAB file or cabinet set

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename = nil) ⇒ Cabinet

Initialize a new cabinet

Parameters:

  • filename (String) (defaults to: nil)

    Path to the cabinet file



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cabriolet/models/cabinet.rb', line 14

def initialize(filename = nil)
  @filename = filename
  @base_offset = 0
  @length = 0
  @set_id = 0
  @set_index = 0
  @flags = 0
  @header_resv = 0
  @prevname = nil
  @nextname = nil
  @previnfo = nil
  @nextinfo = nil
  @folders = []
  @files = []
  @next_cabinet = nil
  @prev_cabinet = nil
  @next = nil
  @blocks_offset = 0
  @block_resv = 0
end

Instance Attribute Details

#base_offsetObject

Returns the value of attribute base_offset.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def base_offset
  @base_offset
end

#block_resvObject (readonly)

Returns the value of attribute block_resv.



9
10
11
# File 'lib/cabriolet/models/cabinet.rb', line 9

def block_resv
  @block_resv
end

#blocks_offsetObject (readonly)

Returns the value of attribute blocks_offset.



9
10
11
# File 'lib/cabriolet/models/cabinet.rb', line 9

def blocks_offset
  @blocks_offset
end

#filenameObject

Returns the value of attribute filename.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def filename
  @filename
end

#filesObject

Returns the value of attribute files.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def files
  @files
end

#flagsObject

Returns the value of attribute flags.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def flags
  @flags
end

#foldersObject

Returns the value of attribute folders.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def folders
  @folders
end

#header_resvObject

Returns the value of attribute header_resv.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def header_resv
  @header_resv
end

#lengthObject

Returns the value of attribute length.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def length
  @length
end

#nextObject

Returns the value of attribute next.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def next
  @next
end

#next_cabinetObject

Returns the value of attribute next_cabinet.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def next_cabinet
  @next_cabinet
end

#nextinfoObject

Returns the value of attribute nextinfo.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def nextinfo
  @nextinfo
end

#nextnameObject

Returns the value of attribute nextname.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def nextname
  @nextname
end

#prev_cabinetObject

Returns the value of attribute prev_cabinet.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def prev_cabinet
  @prev_cabinet
end

#previnfoObject

Returns the value of attribute previnfo.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def previnfo
  @previnfo
end

#prevnameObject

Returns the value of attribute prevname.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def prevname
  @prevname
end

#set_idObject

Returns the value of attribute set_id.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def set_id
  @set_id
end

#set_indexObject

Returns the value of attribute set_index.



7
8
9
# File 'lib/cabriolet/models/cabinet.rb', line 7

def set_index
  @set_index
end

Instance Method Details

#file_countInteger

Get total number of files

Returns:

  • (Integer)


69
70
71
# File 'lib/cabriolet/models/cabinet.rb', line 69

def file_count
  @files.size
end

#folder_countInteger

Get total number of folders

Returns:

  • (Integer)


76
77
78
# File 'lib/cabriolet/models/cabinet.rb', line 76

def folder_count
  @folders.size
end

#has_next?Boolean

Check if this cabinet has a successor

Returns:

  • (Boolean)


45
46
47
# File 'lib/cabriolet/models/cabinet.rb', line 45

def has_next?
  @flags.anybits?(Constants::FLAG_NEXT_CABINET)
end

#has_prev?Boolean

Check if this cabinet has a predecessor

Returns:

  • (Boolean)


38
39
40
# File 'lib/cabriolet/models/cabinet.rb', line 38

def has_prev?
  @flags.anybits?(Constants::FLAG_PREV_CABINET)
end

#has_reserve?Boolean

Check if this cabinet has reserved space

Returns:

  • (Boolean)


52
53
54
# File 'lib/cabriolet/models/cabinet.rb', line 52

def has_reserve?
  @flags.anybits?(Constants::FLAG_RESERVE_PRESENT)
end

#set_blocks_info(offset, resv) ⇒ void

This method returns an undefined value.

Set the blocks offset and reserved space

Parameters:

  • offset (Integer)

    Offset to data blocks

  • resv (Integer)

    Reserved bytes per block



61
62
63
64
# File 'lib/cabriolet/models/cabinet.rb', line 61

def set_blocks_info(offset, resv)
  @blocks_offset = offset
  @block_resv = resv
end