class HaveAPI::Fs::Fs
Interface with RFuseFS API. Methods called by RFuseFS are redirected to appropriate components.
Constants
- CHECK_FILE
Attributes
api[R]
Public Class Methods
new(api, opts)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 13 def initialize(api, opts) @api = api @mutex = Mutex.new @path_cache = Cache.new(self) @context = Context.new @context.opts = opts @context.url = opts[:device] @context.mountpoint = ::File.realpath(opts[:mountpoint]) @context.cache = @path_cache @context[:fs] = self @root = Factory.create(@context, nil, Components::Root) # @root.context = @context.clone # @root.context[:root] = @root @root.setup Thread.abort_on_exception = true @cleaner = Cleaner.new(self, @root) @cleaner.start @path_cache.start end
Public Instance Methods
can_read?(path)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 58 def can_read?(path) puts "can_read?" p path guard { find_component(path).readable? } end
can_write?(path)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 65 def can_write?(path) puts "can_write?" p path guard { find_component(path).writable? } end
contents(path)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 37 def contents(path) puts "contents" p path guard { find_component(path).contents } end
directory?(path)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 44 def directory?(path) puts "directory?" p path guard { find_component(path).directory? } end
executable?(path)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 72 def executable?(path) puts "executable?" p path guard { find_component(path).executable? } end
file?(path)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 51 def file?(path) puts "file?" p path guard {find_component(path).file? } end
raw_close(path, *args)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 142 def raw_close(path, *args) puts "raw_close" p path guard { find_component(path).raw_close(path, *args) } end
raw_open(path, *args)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 107 def raw_open(path, *args) puts "raw_open" p path guard { find_component(path).raw_open(path, *args) } end
raw_read(path, *args)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 114 def raw_read(path, *args) puts "raw_read" p path guard { find_component(path).raw_read(path, *args) } end
raw_sync(path, *args)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 128 def raw_sync(path, *args) puts "raw_sync" p path guard { find_component(path).raw_sync(path, *args) } end
raw_truncate(path, *args)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 135 def raw_truncate(path, *args) puts "raw_truncate" p path guard { find_component(path).raw_truncate(path, *args) } end
raw_write(path, *args)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 121 def raw_write(path, *args) puts "raw_write" p path guard { find_component(path).raw_write(path, *args) } end
read_file(path)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 93 def read_file(path) puts "read_file" p path guard { find_component(path).read } end
size(path)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 86 def size(path) puts "size" p path guard { find_component(path).size } end
synchronize() { || ... }
click to toggle source
# File lib/haveapi/fs/fs.rb, line 156 def synchronize @mutex.synchronize { yield } end
times(path)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 79 def times(path) puts "times" p path guard { find_component(path).times } end
unmounted()
click to toggle source
# File lib/haveapi/fs/fs.rb, line 149 def unmounted puts "unmounted" @cleaner.stop @path_cache.stop end
write_to(path, str)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 100 def write_to(path, str) puts "write_to" p path guard { find_component(path).write(str) } end
Protected Instance Methods
find_component(path)
click to toggle source
# File lib/haveapi/fs/fs.rb, line 161 def find_component(path) @path_cache.get(path) do t = Time.now names = path.split('/').map { |v| v.to_sym }[1..-1] tmp = @root next(tmp) unless names names.each do |n| tmp = tmp.find(n) if tmp.nil? raise Errno::ENOENT, "'#{path}' not found" else tmp.atime = t end end next(tmp) end end
guard() { || ... }
click to toggle source
# File lib/haveapi/fs/fs.rb, line 185 def guard synchronize { yield } rescue => e raise e if e.is_a?(::SystemCallError) warn "Exception #{e.class}" warn e.backtrace.join("\n") warn e.message raise Errno::EIO, e.message end