Sha256: aea2b41619fba88c9db924b28425ba703da277b74d3bf6ac5a317c982036d2ed

Contents?: true

Size: 1.65 KB

Versions: 21

Compression:

Stored size: 1.65 KB

Contents

class File
  def size
    stat.size
  end unless method_defined? :size

  Backports.alias_method self, :to_path, :path

  class << self
    if RUBY_VERSION < '1.9' # can't see any other reasonable way to test than this
      Backports.convert_all_arguments_to_path self, 0, :delete, :unlink, :join
      Backports.convert_all_arguments_to_path self, 1, :chmod, :lchmod
      Backports.convert_all_arguments_to_path self, 2, :chown, :lchown

      Backports.convert_first_argument_to_path self, :atime, :basename,
        :blockdev?, :chardev?, :ctime, :directory?, :dirname, :executable?, :executable_real?,
        :exist?, :exists?, :expand_path, :extname, :file?, :ftype, :grpowned?,
        :link, :lstat, :mtime, :new, :open, :owned?, :pipe?, :readable?, :readable_real?,
        :readlink, :rename, :setgid?, :setuid?, :size, :size?, :socket?,
        :split, :stat, :sticky?, :symlink, :symlink?, :truncate, :writable?,
        :writable_real?, :zero?
    end

    begin
      File.open(__FILE__, :mode => 'r').close
    rescue StandardError
      def open_with_options_hash(file, mode = nil, perm = Backports::Undefined, options = Backports::Undefined)
        mode, perm = Backports.combine_mode_perm_and_option(mode, perm, options)
        perm ||= 0666 # Avoid error on Rubinius, see issue #52
        if block_given?
          open_without_options_hash(file, mode, perm){|f| yield f}
        else
          open_without_options_hash(file, mode, perm)
        end
      end

      Backports.alias_method_chain self, :open, :options_hash
    end
  end

  module Constants
    # In Ruby 1.8, it is defined only on Windows
    BINARY = 0 unless const_defined?(:BINARY)
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
backports-3.0.3 lib/backports/1.9.1/file.rb
backports-3.0.2 lib/backports/1.9.1/file.rb
backports-3.0.1 lib/backports/1.9.1/file.rb
backports-3.0.0 lib/backports/1.9.1/file.rb
backports-2.8.2 lib/backports/1.9.1/file.rb
backports-2.8.1 lib/backports/1.9.1/file.rb
backports-2.8.0 lib/backports/1.9.1/file.rb
backports-2.7.1 lib/backports/1.9.1/file.rb
backports-2.7.0 lib/backports/1.9.1/file.rb
backports-2.6.7 lib/backports/1.9.1/file.rb
backports-2.6.6 lib/backports/1.9.1/file.rb
backports-2.6.5 lib/backports/1.9.1/file.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/backports-2.6.4/lib/backports/1.9.1/file.rb
backports-2.6.4 lib/backports/1.9.1/file.rb
backports-2.6.3 lib/backports/1.9.1/file.rb
backports-2.6.2 lib/backports/1.9.1/file.rb
backports-2.6.1 lib/backports/1.9.1/file.rb
backports-2.6.0 lib/backports/1.9.1/file.rb
backports-2.5.3 lib/backports/1.9.1/file.rb
backports-2.5.2 lib/backports/1.9.1/file.rb