Check file is writable if file exists Check directory is writable if file does not exist
@param [String] path File path @return [Boolean] file is writable or not
# File lib/fluent/plugin/file_util.rb, line 24 def writable?(path) return false if File.directory?(path) return File.writable?(path) if File.exist?(path) dirname = File.dirname(path) return false if !File.directory?(dirname) File.writable?(dirname) end
Check file is writable in conjunction wtih mkdir_p(dirname(path))
@param [String] path File path @return [Boolean] file writable or not
# File lib/fluent/plugin/file_util.rb, line 38 def writable_p?(path) return false if File.directory?(path) return File.writable?(path) if File.exist?(path) dirname = File.dirname(path) until File.exist?(dirname) dirname = File.dirname(dirname) end return false if !File.directory?(dirname) File.writable?(dirname) end
Check file is writable if file exists Check directory is writable if file does not exist
@param [String] path File path @return [Boolean] file is writable or not
# File lib/fluent/plugin/file_util.rb, line 24 def writable?(path) return false if File.directory?(path) return File.writable?(path) if File.exist?(path) dirname = File.dirname(path) return false if !File.directory?(dirname) File.writable?(dirname) end
Check file is writable in conjunction wtih mkdir_p(dirname(path))
@param [String] path File path @return [Boolean] file writable or not
# File lib/fluent/plugin/file_util.rb, line 38 def writable_p?(path) return false if File.directory?(path) return File.writable?(path) if File.exist?(path) dirname = File.dirname(path) until File.exist?(dirname) dirname = File.dirname(dirname) end return false if !File.directory?(dirname) File.writable?(dirname) end