Class: Tilt::Fs::FileSystem::Core
- Inherits:
-
Object
- Object
- Tilt::Fs::FileSystem::Core
- Defined in:
- lib/tilt/fs/file_system/core.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#mount_point ⇒ Object
readonly
Returns the value of attribute mount_point.
-
#root_dir ⇒ Object
readonly
Returns the value of attribute root_dir.
-
#src_path ⇒ Object
readonly
Returns the value of attribute src_path.
-
#template_data_file ⇒ Object
readonly
Returns the value of attribute template_data_file.
Instance Method Summary collapse
- #getattr(ctx, path) ⇒ Object
- #init(ctx, rfuse_info) ⇒ Object
-
#initialize(new_mount_point, new_src_path = "./") ⇒ Core
constructor
A new instance of Core.
- #open(ctx, path, ffi) ⇒ Object
- #read(ctx, path, size, offset, ffi) ⇒ Object
- #readdir(ctx, path, filter, offset, ffi) ⇒ Object
Constructor Details
#initialize(new_mount_point, new_src_path = "./") ⇒ Core
Returns a new instance of Core.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tilt/fs/file_system/core.rb', line 11 def initialize(new_mount_point, new_src_path = "./") @logger = FS_LOGGER @src_path = new_src_path @template_data_file = ::File.join(::Dir.pwd, FS_DEFAULT_DATA_FILE) @root_dir = Dir.new(src_path, template_data_file) @mount_point = new_mount_point logger.debug "core#new(): created" logger.info "Mounted into #{mount_point} from #{src_path}" logger.info "Template data path = #{template_data_file}" end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/tilt/fs/file_system/core.rb', line 5 def logger @logger end |
#mount_point ⇒ Object (readonly)
Returns the value of attribute mount_point.
7 8 9 |
# File 'lib/tilt/fs/file_system/core.rb', line 7 def mount_point @mount_point end |
#root_dir ⇒ Object (readonly)
Returns the value of attribute root_dir.
6 7 8 |
# File 'lib/tilt/fs/file_system/core.rb', line 6 def root_dir @root_dir end |
#src_path ⇒ Object (readonly)
Returns the value of attribute src_path.
8 9 10 |
# File 'lib/tilt/fs/file_system/core.rb', line 8 def src_path @src_path end |
#template_data_file ⇒ Object (readonly)
Returns the value of attribute template_data_file.
9 10 11 |
# File 'lib/tilt/fs/file_system/core.rb', line 9 def template_data_file @template_data_file end |
Instance Method Details
#getattr(ctx, path) ⇒ Object
50 51 52 53 |
# File 'lib/tilt/fs/file_system/core.rb', line 50 def getattr(ctx, path) logger.debug "Core#getattr(): path = #{path}" root_dir.find(path).attr end |
#init(ctx, rfuse_info) ⇒ Object
23 24 25 |
# File 'lib/tilt/fs/file_system/core.rb', line 23 def init(ctx, rfuse_info) logger.info "Tilt::Fs started." end |
#open(ctx, path, ffi) ⇒ Object
40 41 42 |
# File 'lib/tilt/fs/file_system/core.rb', line 40 def open(ctx, path, ffi) logger.debug "Core#open(): path = #{path}" end |
#read(ctx, path, size, offset, ffi) ⇒ Object
44 45 46 47 48 |
# File 'lib/tilt/fs/file_system/core.rb', line 44 def read(ctx, path, size, offset, ffi) logger.info "READ_FILE: #{::File.join mount_point, path}" logger.debug "Core#read(): path = #{path}, size = #{size}" root_dir.find(path).content end |
#readdir(ctx, path, filter, offset, ffi) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tilt/fs/file_system/core.rb', line 27 def readdir(ctx, path, filter, offset, ffi) logger.info "READ_DIR: #{::File.join mount_point, path}" logger.debug "Core#readdir(): ctx = #{ctx}, path = #{path}" dir = root_dir.find(path) raise ::Errno::ENOTDIR.new(path) unless dir.is_dir? token = ::Pathname.new(path).basename.to_s dir.search(token).each do |entry| filter.push entry.name, entry.attr, 0 end end |