Sha256: f9ed4925c37e5cecc8566fd04eb7b2c391076b0e5d0153567e7b90a3d2c6b617
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
require 'irods4r/directory' module IRODS4r #class NotFoundException < Exception; end class NoFileException < Exception; end class FileExistsException < Exception; end # This class proxies a file in an iRODS environment # class File # Create a file resource 'path'. If 'must_not_exist' is true, # throw exception if resource already exists. # def self.create(path, must_not_exist = true, opts = {}) if must_not_exist raise FileExistsException.new(path) if ICommands.exist?(path) end self.new(path, opts) end # Return the content of this file def read() ICommands.read(@path, @ticket) end # Write content to this file. # # WARN: This will overwrite any previous content # def write(content) dir_name = ::File.dirname(@path) ICommands.mkpath(dir_name) unless IRODS4r.exists?(dir_name) ICommands.write(@path, content, @ticket) end def file? return true end def directory? return false end attr_reader :path private def initialize(path, opts = {}) @path = path @ticket = opts[:ticket] end end end
Version data entries
6 entries across 6 versions & 1 rubygems