594: def remove_existing(should)
595: return unless s = stat
596:
597: self.fail "Could not back up; will not replace" unless perform_backup
598:
599: unless should.to_s == "link"
600: return if s.ftype.to_s == should.to_s
601: end
602:
603: case s.ftype
604: when "directory"
605: if self[:force] == :true
606: debug "Removing existing directory for replacement with #{should}"
607: FileUtils.rmtree(self[:path])
608: else
609: notice "Not removing directory; use 'force' to override"
610: end
611: when "link", "file"
612: debug "Removing existing #{s.ftype} for replacement with #{should}"
613: File.unlink(self[:path])
614: else
615: self.fail "Could not back up files of type #{s.ftype}"
616: end
617: expire
618: end