about summary refs log tree commit diff stats
path: root/code
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-06-18 01:16:24 +0200
committerhut <hut@lavabit.com>2009-06-18 01:16:24 +0200
commite07a7764f57ba94b8ab29731981399496ee66c24 (patch)
tree7f05fca851b53b7e32484f72a0b92ffa624925f0 /code
parentdcb1b8c62f7a14a84e06a5ccd8a677f622b3cf2e (diff)
downloadranger-e07a7764f57ba94b8ab29731981399496ee66c24.tar.gz
show free disk space
Diffstat (limited to 'code')
-rw-r--r--code/directory.rb13
-rw-r--r--code/fm/draw.rb2
2 files changed, 14 insertions, 1 deletions
diff --git a/code/directory.rb b/code/directory.rb
index 10966a4a..fd5f0cae 100644
--- a/code/directory.rb
+++ b/code/directory.rb
@@ -11,6 +11,7 @@ class Directory
 		@pointed_file = nil
 		@width = 1000
 		@read = false
+		@free_space = nil
 		@empty = true
 		@scheduled = false
 
@@ -114,6 +115,18 @@ class Directory
 		resize
 	end
 
+	def free_space()
+		if @free_space then return @free_space end
+
+		@free_space = 0
+		out = `df -B 1 #{~path}`
+		out = out[out.index("\n")+1, out.index("\n", out.index("\n"))]
+		if out =~ /^[^\s]+ \s+ \d+ \s+ \d+ \s+  (\d+)  \s+/x
+			@free_space = $1.to_i
+		end
+		@free_space
+	end
+
 	def size() @files.size end
 
 	def resize()
diff --git a/code/fm/draw.rb b/code/fm/draw.rb
index 9d12afb1..45c654a8 100644
--- a/code/fm/draw.rb
+++ b/code/fm/draw.rb
@@ -283,7 +283,7 @@ module Fm
 #				log "Buffer: #{@buffer}"
 				attr_set(Color.base)
 				attr_set(Color.info)
-				puti btm, "#@buffer    #{@pwd.file_size.bytes(false)},#{@pwd.size},#{@pwd.pos+1}    ".rjust(cols)
+				puti btm, "#@buffer    #{@pwd.file_size.bytes(false)}, #{@pwd.free_space.bytes(false)} free, #{@pwd.size}, #{@pwd.pos+1}    ".rjust(cols)
 				more = ''
 				if cf.symlink?
 					more = "#{cf.readlink}"