class FuseFS::DirLink
A FuseFS
over an existing directory
Public Class Methods
new(dir)
click to toggle source
# File lib/fusefs/dirlink.rb, line 6 def initialize(dir) File.directory?(dir) or raise ArgumentError, "DirLink.initialize expects a valid directory!" @base = dir end
Public Instance Methods
contents(path)
click to toggle source
# File lib/fusefs/dirlink.rb, line 23 def contents(path) fn = File.join(@base,path) Dir.entries(fn).map { |file| file = file.sub(/^#{fn}\/?/,'') if ['..','.'].include?(file) nil else file end }.compact.sort end
directory?(path)
click to toggle source
# File lib/fusefs/dirlink.rb, line 11 def directory?(path) File.directory?(File.join(@base,path)) end
file?(path)
click to toggle source
# File lib/fusefs/dirlink.rb, line 15 def file?(path) File.file?(File.join(@base,path)) end
read_file(path)
click to toggle source
# File lib/fusefs/dirlink.rb, line 35 def read_file(path) fn = File.join(@base,path) if File.file?(fn) IO.read(fn) else 'No such file' end end
size(path)
click to toggle source
# File lib/fusefs/dirlink.rb, line 19 def size(path) File.size(File.join(@base,path)) end