Moved common attributes to extfslib, uadf now will complain on nodos or
corrupted images.
This commit is contained in:
@@ -79,7 +79,7 @@ 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.
|
||||
In case of corrupted or no-dos images, message will be shown.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
@@ -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 <gryf73@gmail.com>
|
||||
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()
|
||||
|
||||
|
||||
17
uadf
17
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 <gryf73@gmail.com>
|
||||
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'),
|
||||
|
||||
9
ulha
9
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 <gryf73@gmail.com>
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user