Commit ec6204a6 by Peter Wu

Fix custom output directory for extracted files

Fixes regression since 5fdad3c5 which
ignored the -C option and wrote all files in the current working
directory.

Tested with:

    touch foo && gzip foo && mkdir bar
    binwalk -e foo.gz -C bar
    binwalk -e foo.gz
parent 0efe0e13
......@@ -102,8 +102,11 @@ class Extractor(Module):
def load(self):
# Holds a list of extraction rules loaded either from a file or when manually specified.
self.extract_rules = []
# The input file specific output directory path (to be determined at runtime)
self.directory = None
# The input file specific output directory path (default to CWD)
if self.base_directory:
self.directory = os.path.realpath(self.base_directory)
else:
self.directory = os.getcwd()
# Key value pairs of input file path and output extraction path
self.output = {}
# Number of extracted files
......@@ -426,10 +429,6 @@ class Extractor(Module):
basedir = os.path.dirname(path)
basename = os.path.basename(path)
# Make sure we put the initial extraction directory in the CWD
if self.directory is None:
self.directory = os.getcwd()
if basedir != self.directory:
# During recursive extraction, extracted files will be in subdirectories
# of the CWD. This allows us to figure out the subdirectory by simply
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment