class RubySMB::SMB2::Packet::QueryDirectoryResponse

An SMB2 Query Directory Response Packet as defined in [2.2.34 SMB2 QUERY_DIRECTORY Response](msdn.microsoft.com/en-us/library/cc246552.aspx)

Constants

COMMAND

Public Instance Methods

initialize_instance() click to toggle source
# File lib/ruby_smb/smb2/packet/query_directory_response.rb, line 16
def initialize_instance
  super
  smb2_header.flags.reply = 1
end
results(klass) click to toggle source

Returns the File Information in an array of appropriate structs for the given FileInformationClass. Pulled out of the string buffer.

@param klass [Class] the FileInformationClass class to read the data as @return [array<BinData::Record>] An array of structs holding the requested information @raise [RubySMB::Error::InvalidPacket] if the string buffer is not a valid File Information

# File lib/ruby_smb/smb2/packet/query_directory_response.rb, line 28
def results(klass)
  information_classes = []
  blob = buffer.to_binary_s.dup
  until blob.empty?
    length = blob[0, 4].unpack('V').first

    data = if length.zero?
             blob.slice!(0, blob.length)
           else
             blob.slice!(0, length)
           end

    begin
      information_classes << klass.read(data)
    rescue IOError
      raise RubySMB::Error::InvalidPacket, "Invalid #{klass} File Information in the string buffer"
    end
  end
  information_classes
end