homebrew-cask-versions/lib/hbc/artifact/hardlinked.rb
Roland Walker 202d6019f8 Move all code under an Hbc:: namespace
* convert existing Cask:: namespace to Hbc::
* move Homebrew-fork code under Hbc::
* move freestanding classes such as Tty and TopologicalHash under Hbc::
* recast HOMEBREW_CASK_ constants as HBC_
* modify our Homebrew Formula for backward compatibility
* devscripts and dev docs
2015-01-02 07:27:03 -05:00

24 lines
649 B
Ruby

class Hbc::Artifact::Hardlinked < Hbc::Artifact::Symlinked
def self.islink?(path)
return false unless path.respond_to?(:stat)
path.stat.nlink > 1
end
def self.link_type_english_name
'Hardlink'
end
def create_filesystem_link(source, target)
Pathname.new(target).dirname.mkpath
@command.run!('/bin/ln', :args => ['-hf', '--', source, target])
add_altname_metadata source, target
end
def summarize_one_link(artifact_spec)
load_specification artifact_spec
if self.class.islink?(target)
printable_target = "'#{target}'"
printable_target.sub!(%r{^'#{ENV['HOME']}/*}, %q{~/'})
end
end
end