bin/imager.fuse
changeset 72 2a7ab8422dd6
parent 51 0b6b92d1eb65
child 74 a8495233e04c
--- a/bin/imager.fuse	Wed Aug 17 09:33:59 2011 +0200
+++ b/bin/imager.fuse	Wed Aug 17 12:10:20 2011 +0200
@@ -13,6 +13,7 @@
 use File::Temp;
 use DB_File;
 use File::Basename;
+use Imager;
 
 my %o = (
     debug  => undef,
@@ -217,54 +218,25 @@
         if (not defined $cache{fn}
             or ($cache{fn} ne $fn))
         {
-
             if (-e $fn) {
-                open(my $fh => $fn);
-                binmode($fh);
-                local $/ = undef;
-                $cache{data} = <$fh>;
+		Imager::get_block($fn => \$cache{data});
             }
             elsif (-e "$fn.gz") {
-                open(my $fh => "$fn.gz");
-                binmode($fh);
-                gunzip($fh => \$cache{data})
-                  or die $GunzipError;
+		Imager::get_block("$fn.gz" => \$cache{data});
             }
             elsif (-e "$fn.x") {
-                open(
-                    my $fh =>
-                      "openssl @{[CIPHER]} -d -pass '$o{pass}' -in '$fn.x'|");
-                binmode($fh);
-                local $/ = undef;
-                $cache{data} = <$fh>;
-                close($fh);
+		Imager::get_block("$fn.x" => \$cache{data});
             }
             elsif (-e "$fn.gz.x") {
-                open(
-                    my $fh =>
-                      "openssl @{[CIPHER]} -d -pass '$o{pass}' -in '$fn.gz.x'|"
-                );
-                binmode($fh);
-                gunzip($fh => \$cache{data})
-                  or die $GunzipError;
-                close($fh);
+		Imager::get_block("$fn.gz.x" => \$cache{data});
             }
-            elsif (-e "$fn.x.gz") {
-                warn "$fn.x.gz is depreciated!\n";
-                open(
-                    my $fh =>
-                      "zcat $fn.x.gz | openssl @{[CIPHER]} -d -pass '$o{pass}'|"
-                );
-                binmode($fh);
-                local $/ = undef;
-                $cache{data} = <$fh>;
-                close($fh);
-            }
+	    else {
+		die "Can't get file for $fn";
+	    }
             $cache{fn} = $fn;
         }
 
         return substr($cache{data}, $blockoffset, $length);
-        die "$fn: $!\n";
 
     }