Method: RubySMB::SMB1::File#initialize

Defined in:
lib/ruby_smb/smb1/file.rb

#initialize(tree:, response:, name:) ⇒ File

Returns a new instance of File.

Raises:

  • (ArgumentError)


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ruby_smb/smb1/file.rb', line 51

def initialize(tree:, response:, name:)
  raise ArgumentError, 'No tree provided' if tree.nil?
  raise ArgumentError, 'No response provided' if response.nil?
  raise ArgumentError, 'No file name provided' if name.nil?

  @tree = tree
  @name = name

  @attributes   = response.parameter_block.ext_file_attributes
  @fid          = response.parameter_block.fid
  @last_access  = response.parameter_block.last_access_time.to_datetime
  @last_change  = response.parameter_block.last_change_time.to_datetime
  @last_write   = response.parameter_block.last_write_time.to_datetime
  @size         = response.parameter_block.end_of_file
  @size_on_disk = response.parameter_block.allocation_size
end