module VirtFS::ContextSwitchClassMethods
Public Instance Methods
context()
click to toggle source
# File lib/virtfs/context_switch_class_methods.rb, line 7 def context context_manager.current.current_context end
context!()
click to toggle source
# File lib/virtfs/context_switch_class_methods.rb, line 11 def context! context_manager.current!.current_context end
context_manager()
click to toggle source
# File lib/virtfs/context_switch_class_methods.rb, line 3 def context_manager ContextManager end
cwd=(dir)
click to toggle source
# File lib/virtfs/context_switch_class_methods.rb, line 27 def cwd=(dir) context.restore_cwd_root(dir, nil) end
dir_chdir(dir)
click to toggle source
# File lib/virtfs/context_switch_class_methods.rb, line 40 def dir_chdir(dir) context.chdir(dir) end
dir_chroot(dir)
click to toggle source
# File lib/virtfs/context_switch_class_methods.rb, line 36 def dir_chroot(dir) context.chroot(dir) end
dir_getwd()
click to toggle source
# File lib/virtfs/context_switch_class_methods.rb, line 44 def dir_getwd context.getwd end
expand_links(p, include_last = true)
click to toggle source
Expand symbolic links in the path. This must be done here, because a symlink in one file system can point to a file in another filesystem.
# File lib/virtfs/context_switch_class_methods.rb, line 60 def expand_links(p, include_last = true) context.expand_links(p, include_last) end
fs_call(fs, path = nil, &block)
click to toggle source
Invoke block withing the given filesystem context
@api private @param fs [VirtFS::FS] filesystem intstance through which to invoke block @param path [String] path to specify to block
@raise [VirtFS::NotImplementedError] if filesystem method does not exist
# File lib/virtfs/context_switch_class_methods.rb, line 78 def fs_call(fs, path = nil, &block) block.arity < 1 ? fs.instance_eval(&block) : fs.instance_exec(path, &block) rescue NoMethodError => err STDOUT.puts err.to_s STDOUT.puts err.backtrace.join("\n") raise VirtFS::NotImplementedError.new(fs, err.name) end
fs_lookup_call(path, raise_full_path = false, include_last = true, &block)
click to toggle source
Invoke block using fully resolved filesystem path
@api private @see .fs_call @see Context#path_lookup
# File lib/virtfs/context_switch_class_methods.rb, line 91 def fs_lookup_call(path, raise_full_path = false, include_last = true, &block) fs, p = path_lookup(path, raise_full_path, include_last) fs_call(fs, p, &block) end
mount(fs_instance, mount_point)
click to toggle source
# File lib/virtfs/context_switch_class_methods.rb, line 15 def mount(fs_instance, mount_point) context.mount(fs_instance, mount_point) end
mounted?(mount_point)
click to toggle source
# File lib/virtfs/context_switch_class_methods.rb, line 23 def mounted?(mount_point) context.mounted?(mount_point) end
normalize_path(p, relative_to = nil)
click to toggle source
# File lib/virtfs/context_switch_class_methods.rb, line 64 def normalize_path(p, relative_to = nil) # When running on windows, File.expand_path will add a drive letter. # Remove it if it's there. VfsRealFile.expand_path(p, relative_to || context.getwd).sub(/^[a-zA-Z]:/, "") # XXX end
path_lookup(path, raise_full_path = false, include_last = true)
click to toggle source
Expand symbolic links and perform mount indirection look up.
# File lib/virtfs/context_switch_class_methods.rb, line 51 def path_lookup(path, raise_full_path = false, include_last = true) context.path_lookup(path, raise_full_path, include_last) end
root()
click to toggle source
# File lib/virtfs/context_switch_class_methods.rb, line 31 def root _cwd, root = context.cwd_root root end
umount(mount_point)
click to toggle source
# File lib/virtfs/context_switch_class_methods.rb, line 19 def umount(mount_point) context.umount(mount_point) end