Sha256: 2e087147e550389e61feafbbe35d68460308f12d18932b6c4b1fb90656551d4e

Contents?: true

Size: 842 Bytes

Versions: 1

Compression:

Stored size: 842 Bytes

Contents

require 'folio/fileobject'

module Folio

  class Link < FileObject

    def initialize(path)
      super
      raise LinkNotFound, "#{path}" unless ::File.symlink?(@path)

      dir  = ::File.dirname(@path)
      name = ::File.readlink(@path)
      file = File.join(dir, name)

      @target = Folio.file(file)
    end

    attr :target

    #--
    # Am I write to think any file object can be linked?
    #++

    def symlink?
      ::File.symlink(path)
    end

    def link?
      ::File.link?(path)
    end
    
    def readlink
      ::File.readlink(path)
    end

    def lchmod(mode)
      ::File.lchmod(mode, path)
    end

    def lchown(own, grp)
      ::File.lchown(own, grp, path)
    end

    def lstat
      ::File.lstat(path)
    end

    #
    def method_missing(s, *a, &b)
      @target.send(s, *a, &b)
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
folio-0.3.0 lib/folio/link.rb