Sha256: 536b7bd7d7a5b4646cf77ef4bd7a67f1cdc66b38b1fc3300ac1be650df482dd5

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 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)
    end
    
    # Write content to this file.
    #
    # WARN: This will overwrite any previous content
    #
    def write(content)
      ICommands.write(@path, content)
    end

    def file?
      return true
    end
    
    def directory?
      return false
    end
    
    attr_reader :path
    
    private
    def initialize(path, opts = {})
      @path = path
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omf_web-0.9.9 lib/irods4r/file.rb
omf_web-0.9.8 lib/irods4r/file.rb