215 |
216 |
216 state %cache; |
217 state %cache; |
217 if (not defined $cache{fn} |
218 if (not defined $cache{fn} |
218 or ($cache{fn} ne $fn)) |
219 or ($cache{fn} ne $fn)) |
219 { |
220 { |
220 |
|
221 if (-e $fn) { |
221 if (-e $fn) { |
222 open(my $fh => $fn); |
222 Imager::get_block($fn => \$cache{data}); |
223 binmode($fh); |
|
224 local $/ = undef; |
|
225 $cache{data} = <$fh>; |
|
226 } |
223 } |
227 elsif (-e "$fn.gz") { |
224 elsif (-e "$fn.gz") { |
228 open(my $fh => "$fn.gz"); |
225 Imager::get_block("$fn.gz" => \$cache{data}); |
229 binmode($fh); |
|
230 gunzip($fh => \$cache{data}) |
|
231 or die $GunzipError; |
|
232 } |
226 } |
233 elsif (-e "$fn.x") { |
227 elsif (-e "$fn.x") { |
234 open( |
228 Imager::get_block("$fn.x" => \$cache{data}); |
235 my $fh => |
|
236 "openssl @{[CIPHER]} -d -pass '$o{pass}' -in '$fn.x'|"); |
|
237 binmode($fh); |
|
238 local $/ = undef; |
|
239 $cache{data} = <$fh>; |
|
240 close($fh); |
|
241 } |
229 } |
242 elsif (-e "$fn.gz.x") { |
230 elsif (-e "$fn.gz.x") { |
243 open( |
231 Imager::get_block("$fn.gz.x" => \$cache{data}); |
244 my $fh => |
232 } |
245 "openssl @{[CIPHER]} -d -pass '$o{pass}' -in '$fn.gz.x'|" |
233 else { |
246 ); |
234 die "Can't get file for $fn"; |
247 binmode($fh); |
235 } |
248 gunzip($fh => \$cache{data}) |
|
249 or die $GunzipError; |
|
250 close($fh); |
|
251 } |
|
252 elsif (-e "$fn.x.gz") { |
|
253 warn "$fn.x.gz is depreciated!\n"; |
|
254 open( |
|
255 my $fh => |
|
256 "zcat $fn.x.gz | openssl @{[CIPHER]} -d -pass '$o{pass}'|" |
|
257 ); |
|
258 binmode($fh); |
|
259 local $/ = undef; |
|
260 $cache{data} = <$fh>; |
|
261 close($fh); |
|
262 } |
|
263 $cache{fn} = $fn; |
236 $cache{fn} = $fn; |
264 } |
237 } |
265 |
238 |
266 return substr($cache{data}, $blockoffset, $length); |
239 return substr($cache{data}, $blockoffset, $length); |
267 die "$fn: $!\n"; |
|
268 |
240 |
269 } |
241 } |
270 |
242 |
271 sub writebuffer { |
243 sub writebuffer { |
272 my $path = $IDX . shift; |
244 my $path = $IDX . shift; |