Sha256: b02299bf03efdd635e467800ba2c6b805abf3a0685c8aa7cd26126e98f15f262

Contents?: true

Size: 1.59 KB

Versions: 27

Compression:

Stored size: 1.59 KB

Contents

module RubySMB
  module Fscc
    module FileInformation
      # The FileRenameInformation Class as defined in
      # [2.4.34.2 FileRenameInformation](https://msdn.microsoft.com/en-us/library/cc704597.aspx)
      class FileRenameInformation < BinData::Record
        CLASS_LEVEL = FileInformation::FILE_RENAME_INFORMATION

        endian :little

        uint8  :replace_if_exists, label: 'Replace If Exists'

        choice :reserved, selection: -> { get_smb_version } do
          uint24 1, label: 'Reserved Space'
          uint56 2, label: 'Reserved Space'
        end

        choice :root_directory, selection: -> { get_smb_version } do
          uint32 1, label: 'Root Directory', initial_value: 0
          uint64 2, label: 'Root Directory', initial_value: 0
        end

        uint32 :file_name_length, label: 'File Name Length', initial_value: -> { file_name.do_num_bytes }
        string :file_name,        label: 'File Name',        read_length: -> { file_name_length }

        def get_smb_version(obj = self)
          # Return version 1 by default in case the structure is not part of a
          # SMB packet. This way, we can still instantiate this structure
          # independently without breaking the "choice" logic.
          return 1 if obj.nil?
          smb_version = if obj.respond_to?(:smb_header)
                          1
                        elsif obj.respond_to?(:smb2_header)
                          2
                        else
                          get_smb_version(obj.parent)
                        end
          return smb_version
        end

      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
ruby_smb-3.3.12 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.3.11 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.3.10 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.3.9 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.3.7 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.3.6 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.3.5 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.3.4 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.3.3 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.3.2 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.3.1 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.3.0 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.2.8 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.2.7 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.2.6 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.2.5 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.2.4 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.2.3 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.2.2 lib/ruby_smb/fscc/file_information/file_rename_information.rb
ruby_smb-3.2.1 lib/ruby_smb/fscc/file_information/file_rename_information.rb