From 6ea3bc61153dce74bfea97acaef9d0416b696a89 Mon Sep 17 00:00:00 2001
From: devttys0 <heffnercj@gmail.com>
Date: Sun, 18 Jan 2015 00:05:34 -0500
Subject: [PATCH] Fixed file open bug when attempting to scan a large number of files at once.

---
 src/binwalk/modules/binvis.py  |  2 +-
 src/binwalk/modules/general.py | 16 ++++++++++------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/binwalk/modules/binvis.py b/src/binwalk/modules/binvis.py
index a542cff..cfa6658 100644
--- a/src/binwalk/modules/binvis.py
+++ b/src/binwalk/modules/binvis.py
@@ -74,7 +74,7 @@ class Plotter(Module):
         self.window.opts['distance'] = self.VIEW_DISTANCE
 
         if len(self.config.target_files) == 1:
-            self.window.setWindowTitle(self.config.target_files[0].name)
+            self.window.setWindowTitle(self.config.target_files[0])
 
     def _print(self, message):
         '''
diff --git a/src/binwalk/modules/general.py b/src/binwalk/modules/general.py
index 208c1e6..089241c 100644
--- a/src/binwalk/modules/general.py
+++ b/src/binwalk/modules/general.py
@@ -123,8 +123,9 @@ class General(Module):
                 sys.exit(0)
 
     def reset(self):
-        for fp in self.target_files:
-            fp.reset()
+        pass
+        #for fp in self.target_files:
+        #    fp.reset()
 
     def __del__(self):
         self._cleanup()
@@ -133,9 +134,10 @@ class General(Module):
         self._cleanup()
 
     def _cleanup(self):
-        if hasattr(self, 'target_files'):
-            for fp in self.target_files:
-                fp.close()
+        pass
+        #if hasattr(self, 'target_files'):
+        #    for fp in self.target_files:
+        #        fp.close()
 
     def _set_verbosity(self):
         '''
@@ -171,7 +173,9 @@ class General(Module):
             if not self.subclass == io.FileIO or not os.path.isdir(tfile):
                 # Make sure we can open the target files
                 try:
-                    self.target_files.append(self.open_file(tfile))
+                    fp = self.open_file(tfile)
+                    fp.close()
+                    self.target_files.append(tfile)
                 except KeyboardInterrupt as e:
                     raise e
                 except Exception as e:
--
libgit2 0.26.0