class Pione::Util::FTPOnMemoryFS

OnMemoryFS is a virtual file system on memory.

Constants

ROOT

Attributes

directory[R]
file[R]
mtime[R]

Public Class Methods

new() click to toggle source
# File lib/pione/util/ftp-server.rb, line 148
def initialize
  @directory = {ROOT => Set.new}
  @file = {}
  @mtime = {}
end

Public Instance Methods

clear() click to toggle source

Clear file system items.

@return [void]

# File lib/pione/util/ftp-server.rb, line 157
def clear
  @directory.clear
  @directory[ROOT] = Set.new
  @file.clear
  @mtime.clear
end
delete_file(path) click to toggle source
# File lib/pione/util/ftp-server.rb, line 182
def delete_file(path)
  @directory[path.dirname].delete(path.basename)
  @file.delete(path)
  @mtime.delete(path)
end
directory?(path) click to toggle source
# File lib/pione/util/ftp-server.rb, line 164
def directory?(path)
  @directory.has_key?(path)
end
entries(path) click to toggle source
# File lib/pione/util/ftp-server.rb, line 196
def entries(path)
  @directory[path]
end
file?(path) click to toggle source
# File lib/pione/util/ftp-server.rb, line 168
def file?(path)
  @file.has_key?(path)
end
get_file(path) click to toggle source
# File lib/pione/util/ftp-server.rb, line 172
def get_file(path)
  @file[path]
end
get_mtime(path) click to toggle source
# File lib/pione/util/ftp-server.rb, line 192
def get_mtime(path)
  @mtime[path]
end
get_size(path) click to toggle source
# File lib/pione/util/ftp-server.rb, line 188
def get_size(path)
  @file[path].bytesize
end
mkdir(path) click to toggle source
# File lib/pione/util/ftp-server.rb, line 200
def mkdir(path)
  @directory[path] = Set.new
  unless path == path.dirname
    @directory[path.dirname] << path.basename
  end
end
mv(from_path, to_path) click to toggle source
# File lib/pione/util/ftp-server.rb, line 214
def mv(from_path, to_path)
  @directory[to_path.dirname] << from_path.basename
  @directory[from_path.dirname].delete(from_path.basename)
  @file[to_path] = @file[from_path]
  @file.delete(from_path)
  @mtime[to_path] = @file[from_path]
  @mtime.delete(to_path)
end
put_file(path, data) click to toggle source
# File lib/pione/util/ftp-server.rb, line 176
def put_file(path, data)
  @directory[path.dirname] << path.basename
  @file[path] = File.read(data)
  @mtime[path] = Time.now
end
rmdir(path) click to toggle source
# File lib/pione/util/ftp-server.rb, line 207
def rmdir(path)
  @directory.delete(path)
  unless path == path.dirname
    @directory[path.dirname].delete(path.basename)
  end
end