Sha256: 9460b0f03c606900c77603c84518589b551d3a4951199031b1fe8f65682b1d74

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'fileutils'

module FileUtils

  # Stage by hard linking included files to a stage directory.
  #
  #   stage_directory   Stage directory.
  #   files             Files to link to stage.
  #
  # TODO: Rename to linkstage or something less likely to name clash?

  def stage(stage_directory, files)
    return stage_directory if dryrun?           # Don't link to stage if dryrun.

    if File.directory?(stage_directory)         # Ensure existance of staging area
      #raise(OverwriteError, stage_directory) unless force?
      rm_r(stage_directory)
    end

    mkdir_p(stage_directory)                    #dir = File.expand_path(stage)

    # TODO: dryrun test here or before folder creation?

    files.each do |f|                 # Link files into staging area.
      file = File.join(stage_directory, f)
      if File.directory?(f)
        mkdir_p(file)
      else
        unless File.exist?(file) and File.mtime(file) >= File.mtime(f)
          ln(f, file) #safe_ln ?
        end
      end
    end

    return stage_directory
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
folio-0.4.0 lib/folio/fileutils.rb