about summary refs log tree commit diff stats
path: root/code/extensions
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-07-19 23:14:17 +0200
committerhut <hut@lavabit.com>2009-07-19 23:14:17 +0200
commit3b20bf79874ec8784799ccd78ac236b9b3838956 (patch)
tree8c528fb1c866094300bbb5f6d10993f88ee96f06 /code/extensions
parent7e08f5ad838c644ae08126d075e1316a68f82357 (diff)
downloadranger-3b20bf79874ec8784799ccd78ac236b9b3838956.tar.gz
wrap up many File calls into one File.stat
Diffstat (limited to 'code/extensions')
-rw-r--r--code/extensions/basic.rb14
1 files changed, 5 insertions, 9 deletions
diff --git a/code/extensions/basic.rb b/code/extensions/basic.rb
index f54c3d75..c07402d7 100644
--- a/code/extensions/basic.rb
+++ b/code/extensions/basic.rb
@@ -135,7 +135,7 @@ class Dir
 	end
 end
 
-class File
+class File::Stat
 	MODES_HASH = {
 		'0' => '---',
 		'1' => '--x',
@@ -146,20 +146,16 @@ class File
 		'6' => 'rw-',
 		'7' => 'rwx'
 	}
-	def self.modestr(f)
-		unless exists?(f)
-			return '----------'
-		end
-
-		if symlink?(f)
+	def modestr
+		if symlink?
 			result = 'l'
-		elsif directory?(f)
+		elsif directory?
 			result = 'd'
 		else
 			result = '-'
 		end
 
-		s = ("%o" % File.stat(f).mode)[-3..-1]
+		s = ("%o" % mode)[-3..-1]
 		for m in s.each_char
 			result << MODES_HASH[m]
 		end