Class: Tilt::Fs::FileSystem::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/tilt/fs/file_system/core.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#loggerObject (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_pointObject (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_dirObject (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_pathObject (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_fileObject (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

Raises:

  • (::Errno::ENOTDIR)


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