File: Test.rb

package info (click to toggle)
ruby-filesystem 0.5-5.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 124 kB
  • ctags: 102
  • sloc: ansic: 441; makefile: 86; ruby: 47
file content (29 lines) | stat: -rw-r--r-- 543 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

require 'filesystem'

ARGV.push '/tmp' if ARGV.empty?

ARGV.each {|d|
  s = FileSystem.stat d
  puts "#{s.path}	#{s.blocks_avail}"
}

begin
  bad = FileSystem.stat '/nono'
rescue  
  puts "Got error with '/nono', good!"
end

puts "Mounted FileSystems:"
mts = FileSystem.mounts
mts.each {|m| puts "#{m.device}	#{m.mount}	#{m.fstype}\n" }

puts "Available FileSystems:"
['/etc/fstab', '/etc/vfstab', '/etc/mnttab'].each do |fst|
  if FileTest.exist?(fst)
    puts "In #{fst}:"
    FileSystem.mounts(fst) {|m| puts m.mount}
    break
  end
end