Re: lzma please



Should anyone be interested, here is the patch I came up with to get mc
to grok LZMA compression. Well, I was done mucking with LHa for now and
was feeling a bit bored.

- - 8< - -
diff -Purp mc-4.6.2-pre1/lib/mc.ext.in mc-4.6.2-pre1.with-lzma/lib/mc.ext.in
--- mc-4.6.2-pre1/lib/mc.ext.in    2006-12-28 03:57:01.000000000 +0000
+++ mc-4.6.2-pre1.with-lzma/lib/mc.ext.in    2008-10-23
02:08:38.000000000 +0000
@@ -129,6 +129,11 @@ regex/\.(qp[rk])$
     Open=%cd %p#utar
     View=%view{ascii} gzip -dc %f 2>/dev/null | tar tvvf -

+# .tar.lzma, .tlz
+regex/\.t(lz|ar\.lzma)$
+    Open=%cd %p#utar
+    View=%view{ascii} lzcat %f 2>/dev/null | tar tvvf -
+
 # tar
 regex/\.(tar|TAR)$
     Open=%cd %p#utar
@@ -537,6 +542,11 @@ type/^bzip
     Open=bzip -dc %f | %var{PAGER:more}
     View=%view{ascii} bzip -dc %f 2>/dev/null

+# lzma
+shell/.lzma
+    Open=lzcat %f | %var{PAGER:more}
+    View=%view{ascii} lzcat %f 2>/dev/null
+
 # compress
 type/^compress
     Open=gzip -dc %f | %var{PAGER:more}
diff -Purp mc-4.6.2-pre1/src/util.c mc-4.6.2-pre1.with-lzma/src/util.c
--- mc-4.6.2-pre1/src/util.c    2005-11-03 02:18:38.000000000 +0000
+++ mc-4.6.2-pre1.with-lzma/src/util.c    2008-10-23 01:59:59.000000000
+0000
@@ -979,6 +979,13 @@ get_compression_type (int fd)
         return COMPRESSION_BZIP2;
     }
     }
+
+    /* LZMA files */
+    if ((magic[0] == 0x5d) && (magic[1] == 0x00) &&
+    (magic[2] == 0x00) && (magic[3] == 0x20)) {
+        return COMPRESSION_LZMA;
+    }
+
     return 0;
}

@@ -989,6 +996,7 @@ decompress_extension (int type)
     case COMPRESSION_GZIP: return "#ugz";
     case COMPRESSION_BZIP:   return "#ubz";
     case COMPRESSION_BZIP2:  return "#ubz2";
+    case COMPRESSION_LZMA:  return "#ulzma";
     }
     /* Should never reach this place */
     fprintf (stderr, "Fatal: decompress_extension called with an
unknown argument\n");
diff -Purp mc-4.6.2-pre1/src/util.h mc-4.6.2-pre1.with-lzma/src/util.h
--- mc-4.6.2-pre1/src/util.h    2006-02-03 17:04:17.000000000 +0000
+++ mc-4.6.2-pre1.with-lzma/src/util.h    2008-10-23 00:52:21.000000000
+0000
@@ -179,7 +179,8 @@ enum compression_type {
     COMPRESSION_NONE,
     COMPRESSION_GZIP,
     COMPRESSION_BZIP,
-    COMPRESSION_BZIP2
+    COMPRESSION_BZIP2,
+    COMPRESSION_LZMA
};

/* Looks for ``magic'' bytes at the start of the VFS file to guess the
diff -Purp mc-4.6.2-pre1/vfs/extfs/sfs.ini
mc-4.6.2-pre1.with-lzma/vfs/extfs/sfs.ini
--- mc-4.6.2-pre1/vfs/extfs/sfs.ini    1998-12-15 15:57:43.000000000 +0000
+++ mc-4.6.2-pre1.with-lzma/vfs/extfs/sfs.ini    2008-10-23
01:22:47.000000000 +0000
@@ -10,6 +10,8 @@ bz/1    bzip < %1 > %3
 ubz/1    bzip -d < %1 > %3
 bz2/1    bzip2 < %1 > %3
 ubz2/1    bzip2 -d < %1 > %3
+lzma/1    lzma < %1 > %3
+ulzma/1    lzma -d < %1 > %3
 tar/1    tar cf %3 %1
 tgz/1    tar czf %3 %1
 uhtml/1    lynx -force_html -dump %1 > %3
- - 8< - -

Once I had reinstalled  mc with this patch, all that remained was to
adjust cons.saver's group ownership to 'tty' and set its setgid bit to
ensure it worked equally well for peon and root on the console.

Reynir H. Stefánsson (reynirhs mi is)
--
"Ranma! Will you please quit defiling the laws of physics? At least use
magic if you are going to do something like that!"

       (Ami, in "Siren's Calling" by WarGiver)





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]