Module: Fluent::Compat::FileUtil
- Defined in:
- lib/fluent/compat/file_util.rb
Class Method Summary collapse
-
.writable?(path) ⇒ Boolean
Check file is writable if file exists Check directory is writable if file does not exist.
-
.writable_p?(path) ⇒ Boolean
Check file is writable in conjunction with mkdir_p(dirname(path)).
Class Method Details
.writable?(path) ⇒ Boolean
Check file is writable if file exists Check directory is writable if file does not exist
25 26 27 28 29 30 31 32 |
# File 'lib/fluent/compat/file_util.rb', line 25 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 |
.writable_p?(path) ⇒ Boolean
Check file is writable in conjunction with mkdir_p(dirname(path))
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fluent/compat/file_util.rb', line 39 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 |