mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2025-01-14 20:30:01 +00:00
Added -d and -t switches for extract subcommand
This commit is contained in:
parent
414ed5f3e3
commit
5dde84c68e
@ -109,12 +109,19 @@ def extract_files(image, files):
|
|||||||
output = dirent.filename
|
output = dirent.filename
|
||||||
if options.lower:
|
if options.lower:
|
||||||
output = output.lower()
|
output = output.lower()
|
||||||
|
if options.dir:
|
||||||
|
if not os.path.exists(options.dir):
|
||||||
|
os.makedirs(options.dir)
|
||||||
|
output = os.path.join(options.dir, output)
|
||||||
if not options.dry_run:
|
if not options.dry_run:
|
||||||
data = image.get_file(dirent)
|
data = image.get_file(dirent)
|
||||||
if os.path.exists(output) and not options.force:
|
if os.path.exists(output) and not options.force:
|
||||||
print("skipping %s, file exists. Use -f to overwrite" % output)
|
print("skipping %s, file exists. Use -f to overwrite" % output)
|
||||||
continue
|
continue
|
||||||
print("extracting %s -> %s" % (name, output))
|
print("extracting %s -> %s" % (name, output))
|
||||||
|
if options.text:
|
||||||
|
data = data.replace(b'\x7f', b'\t')
|
||||||
|
data = data.replace(b'\x9b', b'\n')
|
||||||
with open(output, "wb") as fh:
|
with open(output, "wb") as fh:
|
||||||
fh.write(data)
|
fh.write(data)
|
||||||
else:
|
else:
|
||||||
@ -480,6 +487,8 @@ def run():
|
|||||||
extract_parser.add_argument("-l", "--lower", action="store_true", default=False, help="convert extracted filenames to lower case")
|
extract_parser.add_argument("-l", "--lower", action="store_true", default=False, help="convert extracted filenames to lower case")
|
||||||
#extract_parser.add_argument("-n", "--no-sys", action="store_true", default=False, help="only extract things that look like games (no DOS or .SYS files)")
|
#extract_parser.add_argument("-n", "--no-sys", action="store_true", default=False, help="only extract things that look like games (no DOS or .SYS files)")
|
||||||
extract_parser.add_argument("-e", "--ext", action="store", nargs=1, default=False, help="add the specified extension")
|
extract_parser.add_argument("-e", "--ext", action="store", nargs=1, default=False, help="add the specified extension")
|
||||||
|
extract_parser.add_argument("-d", "--dir", action="store", default=False, help="extract to the specified directory")
|
||||||
|
extract_parser.add_argument("-t", "--text", action="store_true", default=False, help="convert text files to unix-style text files")
|
||||||
extract_parser.add_argument("-f", "--force", action="store_true", default=False, help="allow file overwrites on local filesystem")
|
extract_parser.add_argument("-f", "--force", action="store_true", default=False, help="allow file overwrites on local filesystem")
|
||||||
extract_parser.add_argument("files", metavar="FILENAME", nargs="*", help="if not using the -a/--all option, a file (or list of files) to extract from the disk image.")
|
extract_parser.add_argument("files", metavar="FILENAME", nargs="*", help="if not using the -a/--all option, a file (or list of files) to extract from the disk image.")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user