Class: Mirror
- Inherits:
-
Object
- Object
- Mirror
- Defined in:
- ext/dokan-ruby-0.1.5.1229/sample/mirror.rb
Instance Method Summary collapse
- #cleanup(path, fileinfo) ⇒ Object
- #close(path, fileinfo) ⇒ Object
- #create(path, fileinfo) ⇒ Object
- #flush(path, fileinfo) ⇒ Object
- #get_path(path) ⇒ Object
-
#initialize(dir) ⇒ Mirror
constructor
A new instance of Mirror.
- #lock(path, offset, length, fileinfo) ⇒ Object
- #mkdir(path, fileinfo) ⇒ Object
- #open(path, fileinfo) ⇒ Object
- #opendir(path, fileinfo) ⇒ Object
- #read(path, offset, length, fileinfo) ⇒ Object
-
#readdir(path, fileinfo) ⇒ Object
def readdira(path, fileinfo) end.
- #remove(path, fileinfo) ⇒ Object
- #rename(path, newpath, fileinfo) ⇒ Object
- #rmdir(path, fileinfo) ⇒ Object
- #setattr(path, attr, fileinfo) ⇒ Object
- #stat(path, fileinfo) ⇒ Object
- #truncate(path, length, fileinfo) ⇒ Object
- #unlock(path, offset, length, fileinfo) ⇒ Object
- #unmount(fileinfo) ⇒ Object
- #utime(path, ctime, atime, mtime, fileinfo) ⇒ Object
- #write(path, offset, data, fileinfo) ⇒ Object
Constructor Details
#initialize(dir) ⇒ Mirror
Returns a new instance of Mirror.
6 7 8 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 6 def initialize(dir) @dir = dir end |
Instance Method Details
#cleanup(path, fileinfo) ⇒ Object
60 61 62 63 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 60 def cleanup(path, fileinfo) puts "#cleanup " + path true end |
#close(path, fileinfo) ⇒ Object
55 56 57 58 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 55 def close(path, fileinfo) puts "#close " + path true end |
#create(path, fileinfo) ⇒ Object
23 24 25 26 27 28 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 23 def create(path, fileinfo) puts "#create " + path File.open(get_path(path), File::CREAT|File::BINARY|File::WRONLY) { true } rescue false end |
#flush(path, fileinfo) ⇒ Object
96 97 98 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 96 def flush(path, fileinfo) true end |
#get_path(path) ⇒ Object
10 11 12 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 10 def get_path(path) @dir + path.sub("/", "\\") end |
#lock(path, offset, length, fileinfo) ⇒ Object
161 162 163 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 161 def lock(path, offset, length, fileinfo) true end |
#mkdir(path, fileinfo) ⇒ Object
47 48 49 50 51 52 53 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 47 def mkdir(path, fileinfo) puts "#mkdir " + path Dir.mkdir(get_path(path)) true rescue false end |
#open(path, fileinfo) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 14 def open(path, fileinfo) puts "#open " + path if path == "/" true else File.file?(get_path(path)) end end |
#opendir(path, fileinfo) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 38 def opendir(path, fileinfo) puts "#opendir " + path if path == "/" true else File.directory?(get_path(path)) end end |
#read(path, offset, length, fileinfo) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 65 def read(path, offset, length, fileinfo) puts "#read " + path + " length " + length.to_s + " offset " + offset.to_s; if File.file?(get_path(path)) File.open(get_path(path), "rb") do |file| file.seek(offset) str = file.read(length) str = "" if str == nil str end # File.read(get_path(path), length, offset) else false end rescue false end |
#readdir(path, fileinfo) ⇒ Object
def readdira(path, fileinfo)
end
118 119 120 121 122 123 124 125 126 127 128 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 118 def readdir(path, fileinfo) puts "#readdir " + path if File.directory?(get_path(path)) Dir.entries(get_path(path)) else false end rescue false end |
#remove(path, fileinfo) ⇒ Object
140 141 142 143 144 145 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 140 def remove(path, fileinfo) puts "#remove " + path File.delete(get_path(path)) rescue false end |
#rename(path, newpath, fileinfo) ⇒ Object
147 148 149 150 151 152 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 147 def rename(path, newpath, fileinfo) File.rename(get_path(path), get_path(newpath)) true rescue false end |
#rmdir(path, fileinfo) ⇒ Object
154 155 156 157 158 159 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 154 def rmdir(path, fileinfo) Dir.rmdir(get_path(path)) true rescue false end |
#setattr(path, attr, fileinfo) ⇒ Object
130 131 132 133 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 130 def setattr(path, attr, fileinfo) puts "#setattr " + path false end |
#stat(path, fileinfo) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 100 def stat(path, fileinfo) puts "#stat " + path #[size, attr, ctime, atime, mtime] if File.exist?(get_path(path)) s = File.stat(get_path(path)) [s.size, s.directory? ? Dokan::DIRECTORY : Dokan::NORMAL, s.ctime.to_i, s.atime.to_i, s.mtime.to_i] else false end rescue false end |
#truncate(path, length, fileinfo) ⇒ Object
30 31 32 33 34 35 36 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 30 def truncate(path, length, fileinfo) puts "#truncate " + path File.truncate(get_path(path), length) true rescue false end |
#unlock(path, offset, length, fileinfo) ⇒ Object
165 166 167 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 165 def unlock(path, offset, length, fileinfo) true end |
#unmount(fileinfo) ⇒ Object
169 170 171 172 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 169 def unmount(fileinfo) puts "#unmount" true end |
#utime(path, ctime, atime, mtime, fileinfo) ⇒ Object
135 136 137 138 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 135 def utime(path, ctime, atime, mtime, fileinfo) puts "#utime " + path false end |
#write(path, offset, data, fileinfo) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'ext/dokan-ruby-0.1.5.1229/sample/mirror.rb', line 82 def write(path, offset, data, fileinfo) puts "#write " + path if File.writable?(get_path(path)) File.open(get_path(path), "r+") do |file| file.seek(offset) file.write(data) end else false end rescue false end |