Skip to content
Snippets Groups Projects
Commit 0079b4e8 authored by Julien (jvoisin) Voisin's avatar Julien (jvoisin) Voisin
Browse files

Improve a bit how we're handling "problematic" files in the CLI

parent 3cba2944
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,10 @@ from libmat2 import parser_factory, unsupported_extensions
__version__ = '0.1.1'
def __check_file(filename: str, mode: int = os.R_OK) -> bool:
if not os.path.isfile(filename):
if not os.path.exists(filename):
print("[-] %s is doesn't exist." % filename)
return False
elif not os.path.isfile(filename):
print("[-] %s is not a regular file." % filename)
return False
elif not os.access(filename, mode):
......@@ -89,12 +92,14 @@ def show_parsers():
def __get_files_recursively(files):
for f in files:
if os.path.isfile(f):
yield f
else:
if os.path.isdir(f):
for path, _, _files in os.walk(f):
for _f in _files:
yield os.path.join(path, _f)
fname = os.path.join(path, _f)
if __check_file(fname):
yield fname
elif __check_file(f):
yield f
def main():
arg_parser = create_arg_parser()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment