mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-08-26 16:12:23 +02:00
CommandLine: Fix issue when --output filename doesn't contain an extension.
If the argument is i.e. "--output aaa" ... it returned ".aaa" (hidden filename in linux) then "-1.aaa", "-2.aaa", etc.
This commit is contained in:
@@ -716,19 +716,17 @@ class CommandLine:
|
||||
"""Gets the final filename"""
|
||||
if output_dir is None:
|
||||
raise TypeError("Output directory is not a string")
|
||||
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
|
||||
pref_name_array = self.preferred_filename.split(".")
|
||||
filename, extension = (
|
||||
os.path.join(output_dir, ".".join(pref_name_array[:-1])),
|
||||
pref_name_array[-1],
|
||||
)
|
||||
output_filename = f"{filename}.{extension}"
|
||||
output_filename = os.path.join(output_dir, self.preferred_filename)
|
||||
filename, extension = os.path.splitext(output_filename)
|
||||
|
||||
counter = 1
|
||||
while os.path.exists(output_filename):
|
||||
output_filename = f"{filename}-{counter}.{extension}"
|
||||
output_filename = f"{filename}-{counter}{extension}"
|
||||
counter += 1
|
||||
|
||||
return output_filename
|
||||
|
||||
class CLIMemFileHandler(io.BytesIO, CLIFileHandler):
|
||||
|
||||
Reference in New Issue
Block a user