summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/fsobject/file.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/ranger/fsobject/file.py b/ranger/fsobject/file.py
index 15bfc18b..aa44016e 100644
--- a/ranger/fsobject/file.py
+++ b/ranger/fsobject/file.py
@@ -14,30 +14,27 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 control_characters = set(chr(n) for n in set(range(0, 9)) | set(range(14,32)))
+N_FIRST_BYTES = 20
 
 from .fsobject import FileSystemObject as SuperClass
 class File(SuperClass):
 	is_file = True
 
 	@property
-	def first4bytes(self):
+	def firstbytes(self):
 		try:
-			return self._first4bytes
+			return self._firstbytes
 		except:
 			try:
 				f = open(self.path, 'r')
-				self._first4bytes = f.read(4)
+				self._firstbytes = f.read(N_FIRST_BYTES)
 				f.close()
-				return self._first4bytes
+				return self._firstbytes
 			except:
 				pass
 
 	def is_binary(self):
-		if not self.first4bytes:
-			return
-		if self.first4bytes == "\x7F\x45\x4C\x46":
-			return True
-		if control_characters & set(self.first4bytes):
+		if self.firstbytes and control_characters & set(self.firstbytes):
 			return True
 		return False