Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions dtrx/dtrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,25 @@ def get_filenames(self):
return BaseExtractor.get_filenames(self)


class FATDiskImageExtractor(NoPipeExtractor):
file_type = "FAT disk image"
list_command = ["mdir", "-b", "-a", "-/", "-i"]
extract_command = ["mcopy", "-nspm", "-i"]

def extract_archive(self):
command = self.extract_command + [self.filename, "::", "."]
self.extract_pipe = command
BaseExtractor.extract_archive(self)

def get_filenames(self):
command = self.list_command + [self.filename, "::"]
self.list_pipe = command
for line in NoPipeExtractor.get_filenames(self):
# mtools prefixes with ::/ for the default drive, remove that.
yield re.sub(r"^::[/\\]", "", line)
self.archive.close()


class ZipExtractor(NoPipeExtractor):
file_type = "Zip file"
list_command = ["zipinfo", "-1"]
Expand Down Expand Up @@ -1161,6 +1180,12 @@ class ExtractorBuilder(object):
"extensions": ("tar",),
"magic": ("POSIX tar archive",),
},
"fat": {
"extractors": (FATDiskImageExtractor,),
"mimetypes": ("x-msdos", "x-fat"),
"extensions": ("ima", "vfd"),
"magic": ("DOS/MBR boot sector", "FAT12", "FAT16", "FAT32"),
},
"zip": {
"extractors": (ZipExtractor, SevenExtractor),
"mimetypes": ("zip",),
Expand Down
2 changes: 2 additions & 0 deletions tests/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,7 @@
gem
gz
hdr
ima
jar
lha
lrz
Expand All @@ -970,6 +971,7 @@
tgz
tlz
txz
vfd
xpi
xz
zip
Expand Down