Class: ReiserFS::Utils
- Inherits:
-
Object
- Object
- ReiserFS::Utils
- Defined in:
- lib/fs/ReiserFS/utils.rb
Class Method Summary collapse
- .compareKeys(a, b, fuzzy = true) ⇒ Object
- .dumpKey(key, label = nil) ⇒ Object
- .getKeyDirectoryID(k) ⇒ Object
- .getKeyObjectID(k) ⇒ Object
- .getKeyOffset(k) ⇒ Object
- .getKeyType(k) ⇒ Object
- .type2integer(t) ⇒ Object
- .type2text(t) ⇒ Object
- .typeIsDirect?(t) ⇒ Boolean
- .typeIsDirectory?(t) ⇒ Boolean
- .typeIsIndirect?(t) ⇒ Boolean
- .typeIsStat?(t) ⇒ Boolean
Class Method Details
.compareKeys(a, b, fuzzy = true) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/fs/ReiserFS/utils.rb', line 73 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 |
.dumpKey(key, label = nil) ⇒ Object
3 4 5 |
# File 'lib/fs/ReiserFS/utils.rb', line 3 def self.dumpKey(key, label = nil) "#{label}:\t\{#{key['directory_id']},#{key['object_id']},#{key['offset']},#{key['type']}\}" end |
.getKeyDirectoryID(k) ⇒ Object
57 58 59 |
# File 'lib/fs/ReiserFS/utils.rb', line 57 def self.getKeyDirectoryID(k) k['directory_id'] end |
.getKeyObjectID(k) ⇒ Object
61 62 63 |
# File 'lib/fs/ReiserFS/utils.rb', line 61 def self.getKeyObjectID(k) k['object_id'] end |
.getKeyOffset(k) ⇒ Object
65 66 67 |
# File 'lib/fs/ReiserFS/utils.rb', line 65 def self.getKeyOffset(k) k['offset'] end |
.getKeyType(k) ⇒ Object
69 70 71 |
# File 'lib/fs/ReiserFS/utils.rb', line 69 def self.getKeyType(k) k['type'] end |
.type2integer(t) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fs/ReiserFS/utils.rb', line 44 def self.type2integer(t) case t when 0x20000000, 0xFFFFFFFF return -1 when 0x10000000, 0xFFFFFFFE return -2 end t end |
.type2text(t) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fs/ReiserFS/utils.rb', line 27 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 |
.typeIsDirect?(t) ⇒ Boolean
17 18 19 20 |
# File 'lib/fs/ReiserFS/utils.rb', line 17 def self.typeIsDirect?(t) return true if t == -1 false end |
.typeIsDirectory?(t) ⇒ Boolean
11 12 13 14 15 |
# File 'lib/fs/ReiserFS/utils.rb', line 11 def self.typeIsDirectory?(t) return true if t == 500 return true if t == 3 false end |
.typeIsIndirect?(t) ⇒ Boolean
22 23 24 25 |
# File 'lib/fs/ReiserFS/utils.rb', line 22 def self.typeIsIndirect?(t) return true if t == -2 false end |
.typeIsStat?(t) ⇒ Boolean
7 8 9 |
# File 'lib/fs/ReiserFS/utils.rb', line 7 def self.typeIsStat?(t) t == 0 end |