Class: HaveAPI::Fs::Fs

Inherits:
Object
  • Object
show all
Defined in:
lib/haveapi/fs/fs.rb

Overview

Interface with RFuseFS API. Methods called by RFuseFS are redirected to appropriate components.

Constant Summary collapse

CHECK_FILE =
FuseFS::Fuse::Root::CHECK_FILE[1..-1].to_sym

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, opts) ⇒ Fs

Returns a new instance of Fs.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 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

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



11
12
13
# File 'lib/haveapi/fs/fs.rb', line 11

def api
  @api
end

Instance Method Details

#can_read?(path) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
61
62
63
# 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) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
68
69
70
# 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) ⇒ Object



37
38
39
40
41
42
# File 'lib/haveapi/fs/fs.rb', line 37

def contents(path)
  puts "contents"
  p path

  guard { find_component(path).contents }
end

#directory?(path) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
47
48
49
# File 'lib/haveapi/fs/fs.rb', line 44

def directory?(path)
  puts "directory?"
  p path

  guard { find_component(path).directory? }
end

#executable?(path) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
75
76
77
# File 'lib/haveapi/fs/fs.rb', line 72

def executable?(path)
  puts "executable?"
  p path

  guard { find_component(path).executable? }
end

#file?(path) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
# 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) ⇒ Object



142
143
144
145
146
147
# 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) ⇒ Object



107
108
109
110
111
112
# 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) ⇒ Object



114
115
116
117
118
119
# 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) ⇒ Object



128
129
130
131
132
133
# 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) ⇒ Object



135
136
137
138
139
140
# 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) ⇒ Object



121
122
123
124
125
126
# 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) ⇒ Object



93
94
95
96
97
98
# 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) ⇒ Object



86
87
88
89
90
91
# File 'lib/haveapi/fs/fs.rb', line 86

def size(path)
  puts "size"
  p path

  guard { find_component(path).size }
end

#synchronizeObject



156
157
158
# File 'lib/haveapi/fs/fs.rb', line 156

def synchronize
  @mutex.synchronize { yield }
end

#times(path) ⇒ Object



79
80
81
82
83
84
# File 'lib/haveapi/fs/fs.rb', line 79

def times(path)
  puts "times"
  p path

  guard { find_component(path).times }
end

#unmountedObject



149
150
151
152
153
154
# File 'lib/haveapi/fs/fs.rb', line 149

def unmounted
  puts "unmounted"

  @cleaner.stop
  @path_cache.stop
end

#write_to(path, str) ⇒ Object



100
101
102
103
104
105
# 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