From ffb99d65156307780b29f98c57cc598ca32f2427 Mon Sep 17 00:00:00 2001 From: gryf Date: Thu, 16 May 2013 22:25:28 +0200 Subject: [PATCH] Moved common attributes to extfslib, uadf now will complain on nodos or corrupted images. --- README.rst | 2 +- extfslib.py | 7 ++++++- uadf | 17 +++++++++++++---- ulha | 9 +++++---- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index e6c7fab..b2a03d2 100644 --- a/README.rst +++ b/README.rst @@ -79,7 +79,7 @@ disk images. Due to limitations of the `unadf `_, file access inside disk image is read only. -Note, that in case of no-dos images, directory listing will be empty. +In case of corrupted or no-dos images, message will be shown. Requirements ------------ diff --git a/extfslib.py b/extfslib.py index 5642ddd..ffa871c 100644 --- a/extfslib.py +++ b/extfslib.py @@ -5,11 +5,12 @@ plugins for Midnight Commander. Tested against python 2.7 and mc 4.8.7 Changelog: + 1.1 Added item pattern, and common git/uid attrs 1.0 Initial release Author: Roman 'gryf' Dobosz Date: 2013-05-12 -Version: 1.0 +Version: 1.1 Licence: BSD """ import os @@ -32,11 +33,15 @@ class Archive(object): "read": "r", "write": "w", "delete": "d"} + 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""" if not os.path.exists(fname): raise OSError("No such file or directory `%s'" % fname) + self._uid = os.getuid() + self._gid = os.getgid() self._arch = fname self._contents = self._get_dir() diff --git a/uadf b/uadf index 994c7bf..6756f7b 100755 --- a/uadf +++ b/uadf @@ -18,12 +18,13 @@ if comment or filename already contains any comma. It also requires xdms utility, for optional dms support. Changelog: + 1.2 Added failsafe for filenames in archive with spaces and nodos message. 1.1 Moved common code into extfslib library 1.0 Initial release Author: Roman 'gryf' Dobosz -Date: 2013-05-12 -Version: 1.1 +Date: 2013-05-16 +Version: 1.2 Licence: BSD """ @@ -53,8 +54,6 @@ class UAdf(Archive): "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""" @@ -141,6 +140,10 @@ class UAdf(Archive): Convert filenames to be Unix filesystem friendly Add suffix to show user what kind of file do he dealing with. """ + if not self._contents: + sys.stderr.write("Nodos or archive error\n") + return 1 + for entry in self._contents: sys.stdout.write(self.ITEM % entry) return 0 @@ -151,6 +154,12 @@ class UAdf(Archive): if not real_src: raise IOError("No such file or directory") + if " " in real_src: + sys.stderr.write("unadf is unable to operate on filepath with " + "space inside.\nUse affs to mount image and than" + " extract desired files.\n") + return 1 + extract_dir = mkdtemp() cmd = ["unadf", self._arch, real_src, "-d", extract_dir] if check_call(cmd, stdout=open(os.devnull, 'wb'), diff --git a/ulha b/ulha index 81cdee1..067bcbf 100755 --- a/ulha +++ b/ulha @@ -7,12 +7,13 @@ Tested against python 2.7, lha[1] 1.14 and mc 4.8.7 [1] http://lha.sourceforge.jp Changelog: + 1.2 Moved item pattern to extfslib module 1.1 Moved common code into extfslib library 1.0 Initial release Author: Roman 'gryf' Dobosz -Date: 2013-05-12 -Version: 1.1 +Date: 2013-05-16 +Version: 1.2 Licence: BSD """ import os @@ -43,8 +44,7 @@ class ULha(Archive): "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") + DATETIME = "%(month)s %(day)s %(yh)s" def _get_dir(self): """Prepare archive file listing""" @@ -72,6 +72,7 @@ class ULha(Archive): # really care about real user/group entry['uid'] = self._uid entry['gid'] = self._gid + entry['datetime'] = self.DATETIME % entry if not entry['perms']: entry['perms'] = perms