Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 892583d4d3 | |||
| a212514bbf | |||
| 158bc83a14 | |||
| 103714e9c6 | |||
| 733b8c6d12 | |||
| 2d1c387f38 | |||
| 01b4bf7a41 | |||
| 6b8684b1d7 | |||
| 2e50401a18 | |||
| f0a9e5f85d | |||
| 3d269303d9 | |||
| 0a972a5bce | |||
| e6e8b5c74a | |||
| b84d191632 | |||
| ffb99d6515 | |||
| c8407ff57b |
24
LICENSE
Normal file
24
LICENSE
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
Copyright (c) 2013, Roman Dobosz
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the organization nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software
|
||||||
|
without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL ROMAN DOBOSZ BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
130
README.rst
130
README.rst
@@ -1,129 +1,49 @@
|
|||||||
========================
|
=======================
|
||||||
Midnight Commander extfs
|
Midnight Commander ulzx
|
||||||
========================
|
=======================
|
||||||
|
|
||||||
Those are Midnight Commander extfs plugins for handling several archive types.
|
Midnight Commander extfs plugin for handling lzx Amiga archives.
|
||||||
|
|
||||||
Installation
|
Description
|
||||||
============
|
===========
|
||||||
See individual installation plugins below. Basically it come down to:
|
|
||||||
|
|
||||||
* copying ``extfslib.py`` and plugin files to ``~/.local/share/mc/extfs/``
|
|
||||||
* installing binary handlers (lha, unlzx, xdms and unadf)
|
|
||||||
* adding an entry in ``~/.config/mc/mc.ext``::
|
|
||||||
|
|
||||||
# arch
|
|
||||||
regex/\.pattern$
|
|
||||||
Open=%cd %p/handler_filename://
|
|
||||||
|
|
||||||
ULha
|
|
||||||
====
|
|
||||||
ULha is an extfs plugin which can be used with lha/lzh/lharc archives.
|
|
||||||
Personally, I've use it almost exclusively for archives created long time ago
|
|
||||||
on my Amiga. Both reading and writing into archive was implemented.
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
------------
|
|
||||||
ULha requires `free lha <http://lha.sourceforge.jp>`_ implementation to work.
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
* copy ``extfslib.py`` and ``ulha`` to ``~/.local/share/mc/extfs/``
|
|
||||||
* add or change entry for files handle in ``~/.config/mc/mc.ext``::
|
|
||||||
|
|
||||||
# lha
|
|
||||||
regex/\.[lL]([Hh][aA]|[Zz][hH])$
|
|
||||||
Open=%cd %p/ulha://
|
|
||||||
View=%view{ascii} lha l %f
|
|
||||||
|
|
||||||
ULzx
|
|
||||||
====
|
|
||||||
ULzx is an extfs plugin which can be used to browse and extract lzx archives,
|
ULzx is an extfs plugin which can be used to browse and extract lzx archives,
|
||||||
which are known almost exclusively from Amiga.
|
which are known almost exclusively from Amiga.
|
||||||
|
|
||||||
Due to limitations of
|
Due to limitations of
|
||||||
`unlzx <ftp://us.aminet.net/pub/aminet/misc/unix/unlzx.c.gz.readme>`_ tools,
|
`unlzx <ftp://us.aminet.net/pub/aminet/misc/unix/unlzx.c.gz.readme>`_ tools,
|
||||||
only reading is supported. Also be aware, that
|
only reading is supported. Also be aware, that
|
||||||
`unlzx <ftp://us.aminet.net/pub/aminet/misc/unix/unlzx.c.gz.readme>`_ tool
|
`unlzx <ftp://us.aminet.net/pub/aminet/misc/unix/unlzx.c.gz.readme>`_ cannot
|
||||||
cannot extract files individually, so copying entire archive content is not
|
extract files individually, so copying entire archive content is not
|
||||||
recommended, since on every file a full archive extract would be performed,
|
recommended, since on every single file a full archive extract would be
|
||||||
which in the end would have impact on performance.
|
done, which in the end would have impact on performance.
|
||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
|
|
||||||
ULzx requires
|
ULzx requires
|
||||||
`unlzx <ftp://us.aminet.net/pub/aminet/misc/unix/unlzx.c.gz.readme>`_ tool.
|
`unlzx <ftp://us.aminet.net/pub/aminet/misc/unix/unlzx.c.gz.readme>`_ tool.
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
* copy ``extfslib.py`` and ``ulzx`` to ``~/.local/share/mc/extfs/``
|
|
||||||
* add or change entry for files handle in ``~/.config/mc/mc.ext``::
|
|
||||||
|
|
||||||
# lzx
|
* install `extfslib`_
|
||||||
regex/\.[lL][zZ][xX]$
|
* copy ``ulzx`` to ``~/.local/share/mc/extfs.d/``
|
||||||
Open=%cd %p/ulzx://
|
* add or change entry for files handle in ``~/.config/mc/mc.ext``:
|
||||||
View=%view{ascii} unlzx -v %f
|
|
||||||
|
|
||||||
UAdf
|
.. code:: ini
|
||||||
====
|
|
||||||
UAdf is an extfs plugin suitable for reading .adf, .adz and .dms Amiga floppy
|
|
||||||
disk images. Due to limitations of the
|
|
||||||
`unadf <http://freecode.com/projects/unadf>`_, file access inside disk image is
|
|
||||||
read only.
|
|
||||||
|
|
||||||
Note, that in case of no-dos images, directory listing will be empty.
|
[lzx]
|
||||||
|
Regex=\.lzx$
|
||||||
|
RegexIgnoreCase=true
|
||||||
|
Open=%cd %p/ulzx://
|
||||||
|
View=%view{ascii} unlzx -v %f
|
||||||
|
|
||||||
Requirements
|
License
|
||||||
------------
|
=======
|
||||||
|
|
||||||
It requires the `unadf <http://freecode.com/projects/unadf>`_ utility.
|
This software is licensed under 3-clause BSD license. See LICENSE file for
|
||||||
Unfortunately, the page containing original sources doesn't exists
|
details.
|
||||||
anymore. Luckily, there is a copy of the source (and useful patches) in `Debian
|
|
||||||
repository <http://packages.debian.org/sid/unadf>`_.
|
|
||||||
|
|
||||||
There should be one change made to the source of unadf, though. While using
|
|
||||||
"-lr" switch, unadf by default also displays comments next to file name,
|
|
||||||
separated by the comma. If comment or filename contains comma sign, there is no
|
|
||||||
way to distinguish where filename ends and comment starts. In ``extras``
|
|
||||||
directory there is a patch for fixing this - no comments would be displayed by
|
|
||||||
default.
|
|
||||||
|
|
||||||
First, grab the sources and Debian patches. Apply them. To do this manually,
|
.. _extfslib: https://github.com/gryf/mc_extfslib
|
||||||
extract ``unadf_0.7.11a-3.debian.tar.gz`` and ``unadf_0.7.11a.orig.tar.gz`` into
|
|
||||||
some temporary directory. Apply patches in order like in debian/patches/series
|
|
||||||
file. Then apply patch from extras directory::
|
|
||||||
|
|
||||||
$ mkdir temp
|
|
||||||
$ cd temp
|
|
||||||
$ tar zxf ~/Downloads/unadf_0.7.11a-3.debian.tar.gz
|
|
||||||
$ tar zxf ~/Downloads/unadf_0.7.11a.orig.tar.gz
|
|
||||||
$ cd unadf-0.7.11a
|
|
||||||
$ for i in `cat ../debian/patches/series`; do
|
|
||||||
> patch -Np1 < "../debian/patches/${i}"
|
|
||||||
> done
|
|
||||||
$ patch -Np1 < [path_to_this_repo]/extras/unadf_separate_comment.patch
|
|
||||||
$ make
|
|
||||||
$ cp Demo/unadf [destination_path]
|
|
||||||
|
|
||||||
``unadf`` binary should be placed in ``$PATH``.
|
|
||||||
|
|
||||||
For optional dms support, `xdms <http://zakalwe.fi/~shd/foss/xdms/>`_ utility is
|
|
||||||
needed.
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
* copy ``extfslib.py`` and ``uadf`` to ``~/.local/share/mc/extfs/``
|
|
||||||
* add or change entry for files handle in ``~/.config/mc/mc.ext``::
|
|
||||||
|
|
||||||
# adf
|
|
||||||
type/^Amiga\ .* disk
|
|
||||||
Open=%cd %p/uadf://
|
|
||||||
View=%view{ascii} unadf -lr %f
|
|
||||||
|
|
||||||
# adz
|
|
||||||
regex/\.([aA][dD][zZ])$
|
|
||||||
Open=%cd %p/uadf://
|
|
||||||
|
|
||||||
# dms
|
|
||||||
regex/\.([dD][mM][sS])$
|
|
||||||
Open=%cd %p/uadf://
|
|
||||||
|
|||||||
177
extfslib.py
177
extfslib.py
@@ -1,177 +0,0 @@
|
|||||||
"""
|
|
||||||
extfslib is a library which contains Archive class to support writing extfs
|
|
||||||
plugins for Midnight Commander.
|
|
||||||
|
|
||||||
Tested against python 2.7 and mc 4.8.7
|
|
||||||
|
|
||||||
Changelog:
|
|
||||||
1.0 Initial release
|
|
||||||
|
|
||||||
Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
|
|
||||||
Date: 2013-05-12
|
|
||||||
Version: 1.0
|
|
||||||
Licence: BSD
|
|
||||||
"""
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import re
|
|
||||||
from subprocess import check_output, CalledProcessError
|
|
||||||
|
|
||||||
|
|
||||||
class Archive(object):
|
|
||||||
"""Archive handle. Provides interface to MC's extfs subsystem"""
|
|
||||||
LINE_PAT = re.compile("^(?P<size>)\s"
|
|
||||||
"(?P<perms>)\s"
|
|
||||||
"(?P<uid>)\s"
|
|
||||||
"(?P<gid>)\s"
|
|
||||||
"(?P<date>)\s+"
|
|
||||||
"(?P<time>)\s"
|
|
||||||
"(?P<fpath>)")
|
|
||||||
ARCHIVER = "archiver_name"
|
|
||||||
CMDS = {"list": "l",
|
|
||||||
"read": "r",
|
|
||||||
"write": "w",
|
|
||||||
"delete": "d"}
|
|
||||||
|
|
||||||
def __init__(self, fname):
|
|
||||||
"""Prepare archive content for operations"""
|
|
||||||
if not os.path.exists(fname):
|
|
||||||
raise OSError("No such file or directory `%s'" % fname)
|
|
||||||
self._arch = fname
|
|
||||||
self._contents = self._get_dir()
|
|
||||||
|
|
||||||
def _map_name(self, name):
|
|
||||||
"""MC still have a bug in extfs subsystem, in case of filepaths with
|
|
||||||
leading space. This is workaround to this bug, which replaces leading
|
|
||||||
space with tilda."""
|
|
||||||
if name.startswith(" "):
|
|
||||||
new_name = "".join(["~", name[1:]])
|
|
||||||
return new_name
|
|
||||||
return name
|
|
||||||
|
|
||||||
def _get_real_name(self, name):
|
|
||||||
"""Get real filepath of the file. See _map_name docstring for
|
|
||||||
details."""
|
|
||||||
for item in self._contents:
|
|
||||||
if item['display_name'] == name:
|
|
||||||
return item['fpath']
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _get_dir(self):
|
|
||||||
"""Prepare archive file listing. Expected keys which every entry
|
|
||||||
should have are: size, perms, uid, gid, date, time, fpath and
|
|
||||||
display_name."""
|
|
||||||
contents = []
|
|
||||||
|
|
||||||
out = self._call_command("list")
|
|
||||||
if not out:
|
|
||||||
return
|
|
||||||
|
|
||||||
for line in out.split("\n"):
|
|
||||||
match = self.LINE_PAT.match(line)
|
|
||||||
if not match:
|
|
||||||
continue
|
|
||||||
entry = match.groupdict()
|
|
||||||
contents.append(entry)
|
|
||||||
|
|
||||||
return contents
|
|
||||||
|
|
||||||
def _call_command(self, cmd, src=None, dst=None):
|
|
||||||
"""
|
|
||||||
Return status of the provided command, which can be one of:
|
|
||||||
write
|
|
||||||
read
|
|
||||||
delete
|
|
||||||
list
|
|
||||||
"""
|
|
||||||
command = [self.ARCHIVER, self.CMDS.get(cmd), self._arch]
|
|
||||||
|
|
||||||
if src and dst:
|
|
||||||
command.append(src)
|
|
||||||
command.append(dst)
|
|
||||||
elif src or dst:
|
|
||||||
command.append(src and src or dst)
|
|
||||||
|
|
||||||
try:
|
|
||||||
output = check_output(command)
|
|
||||||
except CalledProcessError:
|
|
||||||
sys.exit(1)
|
|
||||||
return output
|
|
||||||
|
|
||||||
def list(self):
|
|
||||||
"""Output contents of the archive to stdout"""
|
|
||||||
sys.stderr.write("Not supported")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def run(self, dst):
|
|
||||||
"""Execute file out of archive"""
|
|
||||||
sys.stderr.write("Not supported")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def copyout(self, src, dst):
|
|
||||||
"""Copy file out of archive"""
|
|
||||||
sys.stderr.write("Not supported")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def rm(self, dst):
|
|
||||||
"""Remove file from archive"""
|
|
||||||
sys.stderr.write("Not supported")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def mkdir(self, dst):
|
|
||||||
"""Create empty directory in archive"""
|
|
||||||
sys.stderr.write("Not supported")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def rmdir(self, dst):
|
|
||||||
"""Removes directory from archive"""
|
|
||||||
sys.stderr.write("Not supported")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def copyin(self, dst, src=None):
|
|
||||||
"""Copy file to the archive"""
|
|
||||||
sys.stderr.write("Not supported")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
|
||||||
"""Print out usage information"""
|
|
||||||
print ("Usage: %(prg)s {copyin,copyout} ARCHNAME SOURCE DESTINATION\n"
|
|
||||||
"or: %(prg)s list ARCHNAME\n"
|
|
||||||
"or: %(prg)s {mkdir,rm,rmdir,run} ARCHNAME TARGET" %
|
|
||||||
{"prg": sys.argv[0]})
|
|
||||||
|
|
||||||
|
|
||||||
def parse_args(arch_class):
|
|
||||||
"""Retrive and parse arguments from commandline and apply them into passed
|
|
||||||
arch_class class object."""
|
|
||||||
try:
|
|
||||||
if sys.argv[1] not in ('list', 'copyin', 'copyout', 'rm', 'mkdir',
|
|
||||||
"run", "rmdir"):
|
|
||||||
usage()
|
|
||||||
sys.exit(2)
|
|
||||||
except IndexError:
|
|
||||||
usage()
|
|
||||||
sys.exit(2)
|
|
||||||
|
|
||||||
arch = src = dst = None
|
|
||||||
try:
|
|
||||||
arch = sys.argv[2]
|
|
||||||
if sys.argv[1] in ('copyin', 'copyout'):
|
|
||||||
src = sys.argv[3]
|
|
||||||
dst = sys.argv[4]
|
|
||||||
elif sys.argv[1] in ('rm', 'rmdir', 'run', 'mkdir'):
|
|
||||||
dst = sys.argv[3]
|
|
||||||
except IndexError:
|
|
||||||
usage()
|
|
||||||
sys.exit(2)
|
|
||||||
|
|
||||||
call_map = {'copyin': lambda a, s, d: arch_class(a).copyin(s, d),
|
|
||||||
'copyout': lambda a, s, d: arch_class(a).copyout(s, d),
|
|
||||||
'list': lambda a, s, d: arch_class(a).list(),
|
|
||||||
'mkdir': lambda a, s, d: arch_class(a).mkdir(d),
|
|
||||||
'rm': lambda a, s, d: arch_class(a).rm(d),
|
|
||||||
'rmdir': lambda a, s, d: arch_class(a).rmdir(d),
|
|
||||||
'run': lambda a, s, d: arch_class(a).run(d)}
|
|
||||||
|
|
||||||
return call_map[sys.argv[1]](arch, src, dst)
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
diff -ur unadf-0.7.11a.orig/Demo/unadf.c unadf-0.7.11a/Demo/unadf.c
|
|
||||||
--- unadf-0.7.11a.orig/Demo/unadf.c 2013-05-12 17:59:51.214905177 +0200
|
|
||||||
+++ unadf-0.7.11a/Demo/unadf.c 2013-05-12 17:50:06.843420519 +0200
|
|
||||||
@@ -58,6 +58,7 @@
|
|
||||||
puts(" -r : lists directory tree contents");
|
|
||||||
puts(" -c : use dircache data (must be used with -l)");
|
|
||||||
puts(" -s : display entries logical block pointer (must be used with -l)");
|
|
||||||
+ puts(" -m : display file comments, if exists (must be used with -l)");
|
|
||||||
putchar('\n');
|
|
||||||
puts(" -v n : mount volume #n instead of default #0 volume");
|
|
||||||
putchar('\n');
|
|
||||||
@@ -65,7 +66,8 @@
|
|
||||||
puts(" -d dir : extract to 'dir' directory");
|
|
||||||
}
|
|
||||||
|
|
||||||
-void printEnt(struct Volume *vol, struct Entry* entry, char *path, BOOL sect)
|
|
||||||
+void printEnt(struct Volume *vol, struct Entry* entry, char *path, BOOL sect,
|
|
||||||
+ BOOL comment)
|
|
||||||
{
|
|
||||||
/* do not print the links entries, ADFlib do not support them yet properly */
|
|
||||||
if (entry->type==ST_LFILE || entry->type==ST_LDIR || entry->type==ST_LSOFT)
|
|
||||||
@@ -89,7 +91,7 @@
|
|
||||||
printf("%s/",entry->name);
|
|
||||||
else
|
|
||||||
printf("%s",entry->name);
|
|
||||||
- if (entry->comment!=NULL && strlen(entry->comment)>0)
|
|
||||||
+ if (comment && entry->comment!=NULL && strlen(entry->comment)>0)
|
|
||||||
printf(", %s",entry->comment);
|
|
||||||
putchar('\n');
|
|
||||||
|
|
||||||
@@ -199,13 +201,14 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
-void printTree(struct Volume *vol, struct List* tree, char* path, BOOL sect)
|
|
||||||
+void printTree(struct Volume *vol, struct List* tree, char* path, BOOL sect,
|
|
||||||
+ BOOL comment)
|
|
||||||
{
|
|
||||||
char *buf;
|
|
||||||
struct Entry* entry;
|
|
||||||
|
|
||||||
while(tree) {
|
|
||||||
- printEnt(vol, tree->content, path, sect);
|
|
||||||
+ printEnt(vol, tree->content, path, sect, comment);
|
|
||||||
if (tree->subdir!=NULL) {
|
|
||||||
entry = (struct Entry*)tree->content;
|
|
||||||
if (strlen(path)>0) {
|
|
||||||
@@ -215,11 +218,11 @@
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sprintf(buf,"%s/%s", path, entry->name);
|
|
||||||
- printTree(vol, tree->subdir, buf, sect);
|
|
||||||
+ printTree(vol, tree->subdir, buf, sect, comment);
|
|
||||||
free(buf);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
- printTree(vol, tree->subdir, entry->name, sect);
|
|
||||||
+ printTree(vol, tree->subdir, entry->name, sect, comment);
|
|
||||||
}
|
|
||||||
tree = tree->next;
|
|
||||||
}
|
|
||||||
@@ -370,12 +373,10 @@
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
- BOOL rflag, lflag, xflag, cflag, vflag, sflag, dflag, pflag, qflag;
|
|
||||||
+ BOOL rflag, lflag, xflag, cflag, vflag, sflag, dflag, pflag, qflag, mflag;
|
|
||||||
struct List* files, *rtfiles;
|
|
||||||
char *devname, *dirname;
|
|
||||||
- char strbuf[80];
|
|
||||||
unsigned char *extbuf;
|
|
||||||
- int vInd, dInd, fInd, aInd;
|
|
||||||
BOOL nextArg;
|
|
||||||
|
|
||||||
struct Device *dev;
|
|
||||||
@@ -389,8 +390,7 @@
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
- rflag = lflag = cflag = vflag = sflag = dflag = pflag = qflag = FALSE;
|
|
||||||
- vInd = dInd = fInd = aInd = -1;
|
|
||||||
+ rflag = lflag = cflag = vflag = sflag = dflag = pflag = qflag = mflag = FALSE;
|
|
||||||
xflag = TRUE;
|
|
||||||
dirname = NULL;
|
|
||||||
devname = NULL;
|
|
||||||
@@ -430,6 +430,9 @@
|
|
||||||
case 's':
|
|
||||||
sflag = TRUE;
|
|
||||||
break;
|
|
||||||
+ case 'm':
|
|
||||||
+ mflag = TRUE;
|
|
||||||
+ break;
|
|
||||||
case 'c':
|
|
||||||
cflag = TRUE;
|
|
||||||
break;
|
|
||||||
@@ -522,13 +525,13 @@
|
|
||||||
if (!rflag) {
|
|
||||||
cell = list = adfGetDirEnt(vol,vol->curDirPtr);
|
|
||||||
while(cell) {
|
|
||||||
- printEnt(vol,cell->content,"", sflag);
|
|
||||||
+ printEnt(vol,cell->content,"", sflag, mflag);
|
|
||||||
cell = cell->next;
|
|
||||||
}
|
|
||||||
adfFreeDirList(list);
|
|
||||||
} else {
|
|
||||||
cell = list = adfGetRDirEnt(vol,vol->curDirPtr,TRUE);
|
|
||||||
- printTree(vol,cell,"", sflag);
|
|
||||||
+ printTree(vol,cell,"", sflag, mflag);
|
|
||||||
adfFreeDirList(list);
|
|
||||||
}
|
|
||||||
}else if (xflag) {
|
|
||||||
diff -ur unadf-0.7.11a.orig/Demo/unadf.usage unadf-0.7.11a/Demo/unadf.usage
|
|
||||||
--- unadf-0.7.11a.orig/Demo/unadf.usage 2006-12-03 15:27:00.000000000 +0100
|
|
||||||
+++ unadf-0.7.11a/Demo/unadf.usage 2013-05-12 17:40:23.116966854 +0200
|
|
||||||
@@ -3,6 +3,7 @@
|
|
||||||
-r : lists directory tree contents
|
|
||||||
-c : use dircache data (must be used with -l)
|
|
||||||
-s : display entries logical block pointer (must be used with -l)
|
|
||||||
+ -m : display file comments, if exists (must be used with -l)
|
|
||||||
|
|
||||||
-v n : mount volume #n instead of default #0 volume
|
|
||||||
|
|
||||||
168
uadf
168
uadf
@@ -1,168 +0,0 @@
|
|||||||
#! /usr/bin/env python
|
|
||||||
"""
|
|
||||||
UADF Virtual filesystem
|
|
||||||
|
|
||||||
This extfs provides quick and dirty read-only access to disk image files for
|
|
||||||
the Commodore Amiga adf or adz (gzipped adfs) and dms.
|
|
||||||
|
|
||||||
It requires the unadf utility (unfortunately there is no original sources,
|
|
||||||
since authors page doesn't exists anymore. Luckily, there is a copy of the
|
|
||||||
source (and useful patches) in Debian repository:
|
|
||||||
http://packages.debian.org/sid/unadf
|
|
||||||
|
|
||||||
There should be one change made to the source of unadf, though. While using
|
|
||||||
"-lr" switch it by default also displays comments, separated by the comma.
|
|
||||||
However there is no way to distinguish where filename ends and comment starts,
|
|
||||||
if comment or filename already contains any comma.
|
|
||||||
|
|
||||||
It also requires xdms utility, for optional dms support.
|
|
||||||
|
|
||||||
Changelog:
|
|
||||||
1.1 Moved common code into extfslib library
|
|
||||||
1.0 Initial release
|
|
||||||
|
|
||||||
Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
|
|
||||||
Date: 2013-05-12
|
|
||||||
Version: 1.1
|
|
||||||
Licence: BSD
|
|
||||||
"""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import re
|
|
||||||
import os
|
|
||||||
import gzip
|
|
||||||
from subprocess import check_output, check_call, CalledProcessError
|
|
||||||
from tempfile import mkstemp, mkdtemp
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
from extfslib import Archive, parse_args
|
|
||||||
|
|
||||||
|
|
||||||
class UAdf(Archive):
|
|
||||||
"""
|
|
||||||
Class for interact with c1541 program and MC
|
|
||||||
"""
|
|
||||||
LINE_PAT = re.compile('\s*(?P<size>\d+)?'
|
|
||||||
'\s{2}(?P<date>\d{4}/\d{2}/\d{2})'
|
|
||||||
'\s{2}\s?(?P<time>\d+:\d{2}:\d{2})'
|
|
||||||
'\s{2}(?P<fpath>.*)')
|
|
||||||
ARCHIVER = "unadf"
|
|
||||||
DMS = "xdms"
|
|
||||||
CMDS = {"list": "-lr",
|
|
||||||
"read": "r",
|
|
||||||
"write": "w",
|
|
||||||
"delete": "d"}
|
|
||||||
DATETIME = "%s-%s-%s %02d:%s"
|
|
||||||
ITEM = ("%(perms)s 1 %(uid)-8s %(gid)-8s %(size)8s %(datetime)s "
|
|
||||||
"%(display_name)s\n")
|
|
||||||
|
|
||||||
def __init__(self, fname):
|
|
||||||
"""Prepare archive content for operations"""
|
|
||||||
self._clean = True
|
|
||||||
self._arch = fname
|
|
||||||
|
|
||||||
if fname.lower().endswith(".adz"):
|
|
||||||
self._ungzip()
|
|
||||||
|
|
||||||
if fname.lower().endswith(".dms"):
|
|
||||||
self._undms()
|
|
||||||
|
|
||||||
super(UAdf, self).__init__(self._arch)
|
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
"""Cleanup"""
|
|
||||||
if not self._clean:
|
|
||||||
try:
|
|
||||||
os.unlink(self._arch)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def _parse_dt(self, date, time):
|
|
||||||
"""Return parsed datetime which fulfill extfs standards date."""
|
|
||||||
year, month, day = date.split("/")
|
|
||||||
hours, minutes, _unused = time.split(":")
|
|
||||||
return self.DATETIME % (month, day, year, int(hours), minutes)
|
|
||||||
|
|
||||||
def _ungzip(self):
|
|
||||||
"""Create temporary file for ungzipped adf file since unadf does not
|
|
||||||
accept gzipped content in any way including reading from stdin."""
|
|
||||||
fdesc, tmp_fname = mkstemp(suffix=".adf")
|
|
||||||
os.close(fdesc)
|
|
||||||
|
|
||||||
with gzip.open(self._arch) as gobj:
|
|
||||||
with open(tmp_fname, "wb") as fobj:
|
|
||||||
fobj.write(gobj.read())
|
|
||||||
self._arch = tmp_fname
|
|
||||||
self._clean = False
|
|
||||||
|
|
||||||
def _undms(self):
|
|
||||||
"""Create temporary adf file extracted from dms."""
|
|
||||||
fdesc, tmp_fname = mkstemp(suffix=".adf")
|
|
||||||
os.close(fdesc)
|
|
||||||
|
|
||||||
try:
|
|
||||||
check_call([self.DMS, '-q', 'u', self._arch, "+" + tmp_fname])
|
|
||||||
self._arch = tmp_fname
|
|
||||||
self._clean = False
|
|
||||||
except (CalledProcessError, OSError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def _get_dir(self):
|
|
||||||
"""Retrieve directory"""
|
|
||||||
contents = []
|
|
||||||
with open(os.devnull, "w") as fnull:
|
|
||||||
try:
|
|
||||||
out = check_output([self.ARCHIVER, self.CMDS['list'],
|
|
||||||
self._arch], stderr=fnull)
|
|
||||||
except CalledProcessError:
|
|
||||||
return contents
|
|
||||||
|
|
||||||
for line in out.split("\n"):
|
|
||||||
match = self.LINE_PAT.match(line)
|
|
||||||
if not match:
|
|
||||||
continue
|
|
||||||
|
|
||||||
entry = match.groupdict()
|
|
||||||
entry['perms'] = "-rw-r--r--"
|
|
||||||
if not entry['size']:
|
|
||||||
entry['perms'] = "drwxr-xr-x"
|
|
||||||
entry['size'] = "0"
|
|
||||||
entry['display_name'] = self._map_name(entry['fpath'])
|
|
||||||
entry['datetime'] = self._parse_dt(entry['date'], entry['time'])
|
|
||||||
entry['uid'] = self._uid
|
|
||||||
entry['gid'] = self._gid
|
|
||||||
contents.append(entry)
|
|
||||||
|
|
||||||
return contents
|
|
||||||
|
|
||||||
def list(self):
|
|
||||||
"""
|
|
||||||
Output list contents of adf image.
|
|
||||||
Convert filenames to be Unix filesystem friendly
|
|
||||||
Add suffix to show user what kind of file do he dealing with.
|
|
||||||
"""
|
|
||||||
for entry in self._contents:
|
|
||||||
sys.stdout.write(self.ITEM % entry)
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def copyout(self, src, dst):
|
|
||||||
"""Copy file form the adf image."""
|
|
||||||
real_src = self._get_real_name(src)
|
|
||||||
if not real_src:
|
|
||||||
raise IOError("No such file or directory")
|
|
||||||
|
|
||||||
extract_dir = mkdtemp()
|
|
||||||
cmd = ["unadf", self._arch, real_src, "-d", extract_dir]
|
|
||||||
if check_call(cmd, stdout=open(os.devnull, 'wb'),
|
|
||||||
stderr=open(os.devnull, 'wb')) != 0:
|
|
||||||
shutil.rmtree(extract_dir)
|
|
||||||
sys.stderr.write("unadf returned with nonzero exit code\n")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
shutil.move(os.path.join(extract_dir, real_src), dst)
|
|
||||||
shutil.rmtree(extract_dir)
|
|
||||||
|
|
||||||
return 0
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
sys.exit(parse_args(UAdf))
|
|
||||||
172
ulha
172
ulha
@@ -1,172 +0,0 @@
|
|||||||
#! /usr/bin/env python
|
|
||||||
"""
|
|
||||||
Lha Virtual filesystem executive for Midnight Commander.
|
|
||||||
|
|
||||||
Tested against python 2.7, lha[1] 1.14 and mc 4.8.7
|
|
||||||
|
|
||||||
[1] http://lha.sourceforge.jp
|
|
||||||
|
|
||||||
Changelog:
|
|
||||||
1.1 Moved common code into extfslib library
|
|
||||||
1.0 Initial release
|
|
||||||
|
|
||||||
Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
|
|
||||||
Date: 2013-05-12
|
|
||||||
Version: 1.1
|
|
||||||
Licence: BSD
|
|
||||||
"""
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import re
|
|
||||||
import shutil
|
|
||||||
from subprocess import call, check_call, CalledProcessError
|
|
||||||
from tempfile import mkdtemp, mkstemp
|
|
||||||
|
|
||||||
from extfslib import Archive, parse_args
|
|
||||||
|
|
||||||
|
|
||||||
class ULha(Archive):
|
|
||||||
"""Archive handle. Provides interface to MC's extfs subsystem"""
|
|
||||||
|
|
||||||
LINE_PAT = re.compile("^((?P<perms>[d-][rswx-]{9})|(\[generic\])|"
|
|
||||||
"(\[unknown\]))"
|
|
||||||
"((\s+\d+/\d+\s+)|(\s+))"
|
|
||||||
"(?P<uid>)(?P<gid>)" # just for the record
|
|
||||||
"(?P<size>\d+)"
|
|
||||||
"\s+(\*{6}|\d+\.\d%)"
|
|
||||||
"\s(?P<month>[JFMASOND][a-z]{2})\s+" # month
|
|
||||||
"(?P<day>\d+)\s+" # day
|
|
||||||
"(?P<yh>\d{4}|(\d{2}:\d{2}))" # year/hour
|
|
||||||
"\s(?P<fpath>.*)")
|
|
||||||
ARCHIVER = "lha"
|
|
||||||
CMDS = {"list": "lq",
|
|
||||||
"read": "pq",
|
|
||||||
"write": "aq",
|
|
||||||
"delete": "dq"}
|
|
||||||
ITEM = ("%(perms)s 1 %(uid)-8s %(gid)-8s %(size)8s %(month)s %(day)s "
|
|
||||||
"%(yh)s %(display_name)s\n")
|
|
||||||
|
|
||||||
def _get_dir(self):
|
|
||||||
"""Prepare archive file listing"""
|
|
||||||
contents = []
|
|
||||||
|
|
||||||
out = self._call_command("list")
|
|
||||||
if not out:
|
|
||||||
return
|
|
||||||
|
|
||||||
for line in out.split("\n"):
|
|
||||||
# -lhd- can store empty directories
|
|
||||||
perms = "-rw-r--r--"
|
|
||||||
if line.endswith(os.path.sep):
|
|
||||||
line = line[:-1]
|
|
||||||
perms = "drw-r--r--"
|
|
||||||
|
|
||||||
match = self.LINE_PAT.match(line)
|
|
||||||
if not match:
|
|
||||||
continue
|
|
||||||
|
|
||||||
entry = match.groupdict()
|
|
||||||
# UID and GID sometimes can have strange values depending on
|
|
||||||
# the information that was written into archive. Most of the
|
|
||||||
# times I was dealing with Amiga lha archives, so that i don't
|
|
||||||
# really care about real user/group
|
|
||||||
entry['uid'] = self._uid
|
|
||||||
entry['gid'] = self._gid
|
|
||||||
|
|
||||||
if not entry['perms']:
|
|
||||||
entry['perms'] = perms
|
|
||||||
|
|
||||||
entry['display_name'] = self._map_name(entry['fpath'])
|
|
||||||
contents.append(entry)
|
|
||||||
return contents
|
|
||||||
|
|
||||||
def list(self):
|
|
||||||
"""Output contents of the archive to stdout"""
|
|
||||||
for entry in self._contents:
|
|
||||||
sys.stdout.write(self.ITEM % entry)
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def rm(self, dst):
|
|
||||||
"""Remove file from archive"""
|
|
||||||
dst = self._get_real_name(dst)
|
|
||||||
# deleting with quiet option enabled will output nothing, so we get
|
|
||||||
# empty string here or None in case of error. Not smart.
|
|
||||||
if self._call_command('delete', dst=dst) is None:
|
|
||||||
return 1
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def rmdir(self, dst):
|
|
||||||
"""Remove empty directory"""
|
|
||||||
dst = self._get_real_name(dst)
|
|
||||||
if not dst.endswith(os.path.sep):
|
|
||||||
dst += os.path.sep
|
|
||||||
|
|
||||||
if self._call_command('delete', dst=dst) is None:
|
|
||||||
return 1
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def run(self, dst):
|
|
||||||
"""Execute file out of archive"""
|
|
||||||
fdesc, tmp_file = mkstemp()
|
|
||||||
os.close(fdesc)
|
|
||||||
result = 0
|
|
||||||
|
|
||||||
if self.copyout(dst, tmp_file) != 0:
|
|
||||||
result = 1
|
|
||||||
|
|
||||||
os.chmod(tmp_file, int("700", 8))
|
|
||||||
|
|
||||||
try:
|
|
||||||
result = call([tmp_file])
|
|
||||||
finally:
|
|
||||||
try:
|
|
||||||
os.unlink(tmp_file)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def mkdir(self, dst):
|
|
||||||
"""Create empty directory in archive"""
|
|
||||||
return self.copyin(dst)
|
|
||||||
|
|
||||||
def copyin(self, dst, src=None):
|
|
||||||
"""Copy file to the archive or create direcotry inside.
|
|
||||||
If src is empty, create empty directory with dst name."""
|
|
||||||
current_dir = os.path.abspath(os.curdir)
|
|
||||||
|
|
||||||
tmpdir = mkdtemp()
|
|
||||||
arch_abspath = os.path.realpath(self._arch)
|
|
||||||
os.chdir(tmpdir)
|
|
||||||
if src:
|
|
||||||
os.makedirs(os.path.dirname(dst))
|
|
||||||
os.link(src, dst)
|
|
||||||
else:
|
|
||||||
os.makedirs(dst)
|
|
||||||
|
|
||||||
try:
|
|
||||||
result = check_call([self.ARCHIVER, self.CMDS["write"],
|
|
||||||
arch_abspath, dst])
|
|
||||||
except CalledProcessError:
|
|
||||||
return 1
|
|
||||||
finally:
|
|
||||||
os.chdir(current_dir)
|
|
||||||
shutil.rmtree(tmpdir)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def copyout(self, src, dst):
|
|
||||||
"""Copy file out form archive."""
|
|
||||||
src = self._get_real_name(src)
|
|
||||||
fobj = open(dst, "wb")
|
|
||||||
try:
|
|
||||||
result = check_call([self.ARCHIVER, self.CMDS['read'], self._arch,
|
|
||||||
src], stdout=fobj)
|
|
||||||
except CalledProcessError:
|
|
||||||
return 1
|
|
||||||
finally:
|
|
||||||
fobj.close()
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
sys.exit(parse_args(ULha))
|
|
||||||
114
ulzx
114
ulzx
@@ -1,39 +1,41 @@
|
|||||||
#! /usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
Read only, Amiga LZX[1] archiver Virtual filesystem executive for Midnight
|
Read only, Amiga LZX[1] archiver Virtual filesystem executive for Midnight
|
||||||
Commander.
|
Commander.
|
||||||
|
|
||||||
Tested against python 2.7, unlzx[1] 1.1 and mc 4.8.7
|
Tested against python 3.8, unlzx[1] 1.1 and mc 4.8.22
|
||||||
|
|
||||||
[1] ftp://us.aminet.net/pub/aminet/misc/unix/unlzx.c.gz.readme
|
[1] ftp://us.aminet.net/pub/aminet/misc/unix/unlzx.c.gz.readme
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
|
1.3 Code cleanup
|
||||||
|
1.2 Use python3
|
||||||
1.1 Moved common code into extfslib library
|
1.1 Moved common code into extfslib library
|
||||||
1.0 Initial release
|
1.0 Initial release
|
||||||
|
|
||||||
Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
|
Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
|
||||||
Date: 2013-05-12
|
Date: 2023-10-20
|
||||||
Version: 1.1
|
Version: 1.3
|
||||||
Licence: BSD
|
Licence: BSD
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
from subprocess import call, CalledProcessError
|
import subprocess
|
||||||
from tempfile import mkdtemp, mkstemp
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
from extfslib import Archive, parse_args
|
import extfslib
|
||||||
|
|
||||||
|
|
||||||
class ULzx(Archive):
|
class ULzx(extfslib.Archive):
|
||||||
"""Archive handle. Provides interface to MC's extfs subsystem"""
|
"""LZX archive handle. Provides interface to MC's extfs subsystem"""
|
||||||
LINE_PAT = re.compile("^\s+(?P<size>\d+)\s+"
|
LINE_PAT = re.compile(r"^\s+(?P<size>\d+)\s+"
|
||||||
"((n/a)|\d+)\s"
|
r"((n/a)|\d+)\s"
|
||||||
"(?P<time>\d{2}:\d{2}:\d{2})\s+"
|
r"(?P<time>\d{2}:\d{2}:\d{2})\s+"
|
||||||
"(?P<date>\d+-[a-z]{3}-\d{4})\s"
|
r"(?P<date>\d+-[a-z]{3}-\d{4})\s"
|
||||||
"(?P<perms>[h-][s-][p-][a-][r-][w-][e-][d-])\s"
|
r"(?P<perms>[h-][s-][p-][a-][r-][w-][e-][d-])\s"
|
||||||
"\"(?P<fpath>.*)\"")
|
r"\"(?P<fpath>.*)\"")
|
||||||
ARCHIVER = "unlzx"
|
ARCHIVER = "unlzx"
|
||||||
CMDS = {"list": "-v",
|
CMDS = {"list": "-v",
|
||||||
"read": "-x"}
|
"read": "-x"}
|
||||||
@@ -42,32 +44,39 @@ class ULzx(Archive):
|
|||||||
def _get_date(self, time, date):
|
def _get_date(self, time, date):
|
||||||
"""Return MM-DD-YYYY hh:mm formatted date out of time and date
|
"""Return MM-DD-YYYY hh:mm formatted date out of time and date
|
||||||
strings"""
|
strings"""
|
||||||
month_list = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug",
|
month_list = ["jan", "fe", "mar", "apr", "may", "jun", "jul",
|
||||||
"sep", "oct", "nov", "dec"]
|
"aug", "sep", "oct", "nov", "dec"]
|
||||||
day, month, year = date.split("-")
|
day, month, year = date.split("-")
|
||||||
month = month_list.index(month) + 1
|
month = month_list.index(month) + 1
|
||||||
hours, minutes, dummy = time.split(":")
|
hours, minutes, dummy = time.split(":")
|
||||||
return self.DATETIME % (month, int(day), year, int(hours), int(minutes))
|
return self.DATETIME % (month, int(day), year, int(hours),
|
||||||
|
int(minutes))
|
||||||
|
|
||||||
def _get_dir(self):
|
def _get_dir(self):
|
||||||
"""Prepare archive file listing"""
|
"""Prepare archive file listing"""
|
||||||
contents = []
|
contents = []
|
||||||
|
|
||||||
out = self._call_command("list")
|
out = subprocess.run([self.ARCHIVER, self.CMDS['list'], self._arch],
|
||||||
if not out:
|
capture_output=True, encoding="latin-1")
|
||||||
return
|
if out.stderr:
|
||||||
|
sys.stderr.write(out.stderr)
|
||||||
|
|
||||||
for line in out.split("\n"):
|
for line in out.stdout.split("\n"):
|
||||||
match = self.LINE_PAT.match(line)
|
match = self.LINE_PAT.match(line)
|
||||||
if not match:
|
if not match:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
entry = match.groupdict()
|
match_entry = match.groupdict()
|
||||||
|
entry = {}
|
||||||
|
for key in match_entry:
|
||||||
|
entry[key] = match_entry[key]
|
||||||
|
del match_entry
|
||||||
|
|
||||||
entry['datetime'] = self._get_date(entry['time'], entry['date'])
|
entry['datetime'] = self._get_date(entry['time'], entry['date'])
|
||||||
entry['display_name'] = self._map_name(entry['fpath'])
|
entry['display_name'] = self._map_name(entry['fpath'])
|
||||||
entry['perms'] = "-rw-r--r--" # lzx doesn't store empty dirs
|
entry['perms'] = "-rw-r--r--" # lzx doesn't store empty dirs
|
||||||
entry['uid'] = self._uid
|
entry['uid'] = str(self._uid)
|
||||||
entry['gid'] = self._gid
|
entry['gid'] = str(self._gid)
|
||||||
contents.append(entry)
|
contents.append(entry)
|
||||||
|
|
||||||
return contents
|
return contents
|
||||||
@@ -75,12 +84,12 @@ class ULzx(Archive):
|
|||||||
def list(self):
|
def list(self):
|
||||||
"""Output contents of the archive to stdout"""
|
"""Output contents of the archive to stdout"""
|
||||||
for entry in self._contents:
|
for entry in self._contents:
|
||||||
sys.stdout.write(self.ITEM % entry)
|
sys.stdout.write(self.ITEM.decode('utf-8') % entry)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def run(self, dst):
|
def run(self, dst):
|
||||||
"""Execute file out of archive"""
|
"""Execute file out of archive"""
|
||||||
fdesc, tmp_file = mkstemp()
|
fdesc, tmp_file = tempfile.mkstemp()
|
||||||
os.close(fdesc)
|
os.close(fdesc)
|
||||||
result = 0
|
result = 0
|
||||||
|
|
||||||
@@ -89,40 +98,41 @@ class ULzx(Archive):
|
|||||||
|
|
||||||
os.chmod(tmp_file, int("700", 8))
|
os.chmod(tmp_file, int("700", 8))
|
||||||
|
|
||||||
try:
|
with open(os.devnull, "w") as fnull:
|
||||||
result = call([tmp_file])
|
result = subprocess.run([tmp_file], stderr=fnull)
|
||||||
finally:
|
os.unlink(tmp_file)
|
||||||
try:
|
|
||||||
os.unlink(tmp_file)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return result
|
return result.returncode
|
||||||
|
|
||||||
def copyout(self, src, dst):
|
def copyout(self, src, dst):
|
||||||
"""Unfortunately, to copy one file out entire LZX archive have to be
|
"""Unfortunately, to copy one file out entire LZX archive have to be
|
||||||
extracted. For small archives is not a problem, but in relatively big
|
extracted. For small archives is not a problem, but in relatively big
|
||||||
one it could be a performance issue."""
|
one it could be a performance issue."""
|
||||||
tmp_dir = mkdtemp()
|
tmp_dir = tempfile.mkdtemp()
|
||||||
src = self._get_real_name(src)
|
src = [e['display_name'] for e in self._contents
|
||||||
|
if e['display_name'] == src]
|
||||||
|
if not src:
|
||||||
|
raise IOError("No such file or directory")
|
||||||
|
|
||||||
|
src = src[0].encode('latin-1')
|
||||||
|
|
||||||
current_dir = os.path.abspath(os.curdir)
|
current_dir = os.path.abspath(os.curdir)
|
||||||
os.chdir(tmp_dir)
|
os.chdir(tmp_dir)
|
||||||
|
|
||||||
try:
|
with open(os.devnull, "w") as fnull:
|
||||||
with open(os.devnull, "w") as fnull:
|
result = subprocess.run([self.ARCHIVER, self.CMDS['read'],
|
||||||
result = call([self.ARCHIVER, self.CMDS['read'],
|
os.path.join(current_dir, self._arch)],
|
||||||
os.path.join(current_dir, self._arch)],
|
stdout=fnull, stderr=fnull)
|
||||||
stdout=fnull, stderr=fnull)
|
if result.returncode == 0:
|
||||||
if result == 0:
|
# use subprocess, as shutil.copy2 will complain about mixing
|
||||||
shutil.copy2(src, dst)
|
# strings with bytes
|
||||||
except CalledProcessError:
|
subprocess.run(['cp', src, dst])
|
||||||
return 1
|
|
||||||
finally:
|
|
||||||
shutil.rmtree(tmp_dir)
|
|
||||||
os.chdir(current_dir)
|
|
||||||
|
|
||||||
return result
|
shutil.rmtree(tmp_dir)
|
||||||
|
os.chdir(current_dir)
|
||||||
|
|
||||||
|
return result.returncode
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(parse_args(ULzx))
|
sys.exit(extfslib.parse_args(ULzx))
|
||||||
|
|||||||
Reference in New Issue
Block a user