@@ -103,6 +103,7 @@ def parse_index(index_entry)
103
103
def parse_index_list ( index_record , index_allocation_attribute )
104
104
offset_index_entry_list = index_record [ 0 , 4 ] . unpack ( 'V' ) [ 0 ]
105
105
index_size = index_record [ offset_index_entry_list + 8 , 2 ] . unpack ( 'v' ) [ 0 ]
106
+ index_size_in_bytes = index_size * @bytes_per_cluster
106
107
index_entry = index_record [ offset_index_entry_list , index_size ]
107
108
res = { }
108
109
while index_entry [ 12 , 4 ] . unpack ( 'V' ) [ 0 ] & 2 != 2
@@ -112,20 +113,19 @@ def parse_index_list(index_record, index_allocation_attribute)
112
113
# should be 8 bytes length
113
114
vcn = index_entry [ -8 , 4 ] . unpack ( 'V' ) [ 0 ]
114
115
vcn_in_bytes = vcn * @bytes_per_cluster
115
- index_size_in_bytes = index_size * @bytes_per_cluster
116
116
res_son = parse_index_list ( index_allocation_attribute [ vcn_in_bytes + 24 , index_size_in_bytes ] , index_allocation_attribute )
117
117
res . update ( res_son )
118
118
end
119
119
offset_index_entry_list += index_size
120
120
index_size = index_record [ offset_index_entry_list + 8 , 2 ] . unpack ( 'v' ) [ 0 ]
121
+ index_size_in_bytes = index_size * @bytes_per_cluster
121
122
index_entry = index_record [ offset_index_entry_list , index_size ]
122
123
end
123
124
# if son on the last
124
125
if index_entry [ 12 , 4 ] . unpack ( 'V' ) [ 0 ] & 1 == 1
125
126
# should be 8 bytes length
126
127
vcn = index_entry [ -8 , 4 ] . unpack ( 'V' ) [ 0 ]
127
128
vcn_in_bytes = vcn * @bytes_per_cluster
128
- index_size_in_bytes = index_size * @bytes_per_cluster
129
129
res_son = parse_index_list ( index_allocation_attribute [ vcn_in_bytes + 24 , index_size_in_bytes ] , index_allocation_attribute )
130
130
res . update ( res_son )
131
131
end
@@ -153,7 +153,6 @@ def cluster_from_attribute_non_resident(attribute, cluster_num = 0, size_max = (
153
153
attribut = ''
154
154
run_list_num = lowvcn
155
155
old_offset = 0
156
-
157
156
while run_list_num <= highvcn
158
157
first_runlist_byte = attribute [ offset ] . ord
159
158
run_offset_size = first_runlist_byte >> 4
@@ -170,11 +169,12 @@ def cluster_from_attribute_non_resident(attribute, cluster_num = 0, size_max = (
170
169
run_offset += "\x00 " * ( 8 - run_offset_size )
171
170
end
172
171
run_offset = run_offset . unpack ( 'q<' ) [ 0 ]
172
+ #offset relative to previous offset
173
+ run_offset += old_offset
173
174
174
175
size_wanted = [ run_length * @bytes_per_cluster , size_max - attribut . length ] . min
175
-
176
- if cluster_num + ( size_wanted / @bytes_per_cluster ) >= run_list_num && ( cluster_num < run_length + run_list_num )
177
- run_list_offset_in_cluster = run_offset + old_offset + [ cluster_num - run_list_num , 0 ] . max
176
+ if cluster_num + ( size_max / @bytes_per_cluster ) >= run_list_num && ( cluster_num < run_length + run_list_num )
177
+ run_list_offset_in_cluster = run_offset + [ cluster_num - run_list_num , 0 ] . max
178
178
run_list_offset = ( run_list_offset_in_cluster ) * @bytes_per_cluster
179
179
run_list_offset = run_list_offset . to_i
180
180
@file_handler . seek ( run_list_offset )
@@ -183,7 +183,7 @@ def cluster_from_attribute_non_resident(attribute, cluster_num = 0, size_max = (
183
183
while data . length < size_wanted
184
184
data << @file_handler . read ( size_wanted - data . length )
185
185
end
186
- attribut += data
186
+ attribut << data
187
187
end
188
188
offset += run_offset_size + run_length_size + 1
189
189
run_list_num += run_length
0 commit comments