Class: Sshfs

Inherits:
Object
  • Object
show all
Defined in:
ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb

Overview

GC.disable

Instance Method Summary collapse

Constructor Details

#initialize(sftp) ⇒ Sshfs

Returns a new instance of Sshfs.



8
9
10
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 8

def initialize(sftp)
  @sftp = sftp
end

Instance Method Details

#cleanup(path, fileinfo) ⇒ Object



56
57
58
59
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 56

def cleanup(path, fileinfo)
  puts "#cleanup " + path
  true
end

#close(path, fileinfo) ⇒ Object



51
52
53
54
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 51

def close(path, fileinfo)
  puts "#close " + path
  true
end

#create(path, fileinfo) ⇒ Object



22
23
24
25
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 22

def create(path, fileinfo)
  puts "#create " + path
  false
end

#directory?(path) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 82

def directory?(path)
  0 < (@sftp.stat(path).permissions & 040000)
end

#flush(path, fileinfo) ⇒ Object



78
79
80
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 78

def flush(path, fileinfo)
  true
end

#mkdir(path, fileinfo) ⇒ Object



46
47
48
49
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 46

def mkdir(path, fileinfo)
  puts "#mkdir " + path
  false
end

#open(path, fileinfo) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 12

def open(path, fileinfo)
  puts "#open " + path
  @sftp.open_handle(path, "r") do
    true
  end
rescue
  p $!
  false
end

#opendir(path, fileinfo) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 32

def opendir(path, fileinfo)
  puts "#opendir " + path
  if path == "/"
    true
  elsif directory?(path)
    true
  else
    false
  end
rescue
  p $!
  false
end

#read(path, offset, length, fileinfo) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 61

def read(path, offset, length, fileinfo)
  puts "#read " + path
  data = nil
  @sftp.open_handle(path, "r") do |handle|
    data = @sftp.read(handle)
  end
  data != nil ? data[offset, length] : false
rescue
  p $!
  false
end

#readdir(path, fileinfo) ⇒ Object

def readdira(path, fileinfo)

end


105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 105

def readdir(path, fileinfo)
  puts "#readdir " + path
  entries = []
  handle = @sftp.opendir(path)
  items = @sftp.readdir(handle)
  items.each do |item|
    entries.push item.filename
  end
  @sftp.close_handle(handle)
  entries
rescue
  p $!
  false
end

#remove(path, fileinfo) ⇒ Object



130
131
132
133
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 130

def remove(path, fileinfo)
  puts "#remove " + path
  false
end

#rename(path, newpath, fileinfo) ⇒ Object



135
136
137
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 135

def rename(path, newpath, fileinfo)
  false
end

#rmdir(path, fileinfo) ⇒ Object



139
140
141
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 139

def rmdir(path, fileinfo)
  false
end

#setattr(path, attr, fileinfo) ⇒ Object



120
121
122
123
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 120

def setattr(path, attr, fileinfo)
  puts "#setattr " + path
  false
end

#stat(path, fileinfo) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 86

def stat(path, fileinfo)
  puts "#stat " + path
  #[size, attr, ctime, atime, mtime]
  if path == "/"
    [0, Dokan::DIRECTORY, 0, 0, 0]
  else
    s = @sftp.stat(path)
    [s.size,
      0 < (s.permissions & 040000) ? Dokan::DIRECTORY : Dokan::NORMAL,
      s.mtime.to_i, s.atime.to_i, s.mtime.to_i]
   end
rescue
  p $!
  false
end

#truncate(path, length, fileinfo) ⇒ Object



27
28
29
30
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 27

def truncate(path, length, fileinfo)
  puts "#truncate " + path
  false
end

#unmount(fileinfo) ⇒ Object



143
144
145
146
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 143

def unmount(fileinfo)
  puts "#unmount"
  true
end

#utime(path, ctime, atime, mtime, fileinfo) ⇒ Object



125
126
127
128
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 125

def utime(path, ctime, atime, mtime, fileinfo)
  puts "#utime " + path
  false
end

#write(path, offset, data, fileinfo) ⇒ Object



73
74
75
76
# File 'ext/dokan-ruby-0.1.5.1229/sample/sshfs.rb', line 73

def write(path, offset, data, fileinfo)
  puts "#write " + path
  false
end