summaryrefslogtreecommitdiffstats
path: root/lib/puppet/file_serving/file_base.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/file_serving/file_base.rb')
-rw-r--r--lib/puppet/file_serving/file_base.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/puppet/file_serving/file_base.rb b/lib/puppet/file_serving/file_base.rb
index 7f169d1ea..06b3ad9ef 100644
--- a/lib/puppet/file_serving/file_base.rb
+++ b/lib/puppet/file_serving/file_base.rb
@@ -9,16 +9,28 @@ require 'puppet/file_serving'
class Puppet::FileServing::FileBase
attr_accessor :key
+ # Does our file exist?
+ def exist?
+ begin
+ stat
+ return true
+ rescue => detail
+ return false
+ end
+ end
+
# Return the full path to our file. Fails if there's no path set.
def full_path
raise(ArgumentError, "You must set a path to get a file's path") unless self.path
- relative_path ? File.join(path, relative_path) : path
+ if relative_path.nil? or relative_path == ""
+ path
+ else
+ File.join(path, relative_path)
+ end
end
def initialize(key, options = {})
- raise ArgumentError.new("Files must not be fully qualified") if path =~ /^#{::File::SEPARATOR}/
-
@key = key
@links = :manage