Sha256: ec83350dabb11beeef4ad07622a4768d01236ad15fa213e17d006778e1b04353

Contents?: true

Size: 1.8 KB

Versions: 66

Compression:

Stored size: 1.8 KB

Contents

module ReiserFS
  class Utils
    def self.dumpKey(key, label = nil)
      "#{label}:\t\{#{key['directory_id']},#{key['object_id']},#{key['offset']},#{key['type']}\}"
    end

    def self.typeIsStat?(t)
      t == 0
    end

    def self.typeIsDirectory?(t)
      return true if t == 500
      return true if t == 3
      false
    end

    def self.typeIsDirect?(t)
      return true if t == -1
      false
    end

    def self.typeIsIndirect?(t)
      return true if t == -2
      false
    end

    def self.type2text(t)
      case t
      when -1
        return 'direct'
      when -2
        return 'indirect'
      when 0
        return 'stat'
      when 500
        return 'directory'
      when 555
        return 'any'
      else
        raise "Unrecognized Type #{t}"
      end
    end

    def self.type2integer(t)
      case t
      when 0x20000000, 0xFFFFFFFF
        return -1

      when 0x10000000, 0xFFFFFFFE
        return -2

      end

      t
    end

    def self.getKeyDirectoryID(k)
      k['directory_id']
    end

    def self.getKeyObjectID(k)
      k['object_id']
    end

    def self.getKeyOffset(k)
      k['offset']
    end

    def self.getKeyType(k)
      k['type']
    end

    def self.compareKeys(a, b, fuzzy = true)
      # Compare directory IDs
      return (-1) if a['directory_id'] < b['directory_id']
      return (+1) if a['directory_id'] > b['directory_id']

      # Compare Object IDs
      return (-1) if a['object_id'] < b['object_id']
      return (+1) if a['object_id'] > b['object_id']

      if fuzzy == false
        # Compare Offsets
        return (-1) if a['offset'] < b['offset']
        return (+1) if a['offset'] > b['offset']

        # Compare Types
        return (-1) if a['type'] < b['type']
        return (+1) if a['type'] > b['type']
      end

      0
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
manageiq-smartstate-0.10.1 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.10.0 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.9.0 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.8.1 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.8.0 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.7.0 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.6.2 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.5.10 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.3.10 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.6.1 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.3.9 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.6.0 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.5.9 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.5.8 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.3.8 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.5.7 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.3.7 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.5.6 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.3.6 lib/fs/ReiserFS/utils.rb
manageiq-smartstate-0.5.5 lib/fs/ReiserFS/utils.rb