Class: Puppet::FileSystem::JRuby

Inherits:
Posix show all
Defined in:
lib/puppet/file_system/jruby.rb

Instance Method Summary collapse

Methods inherited from Posix

#binread, #compare_stream

Methods inherited from FileImpl

#assert_path, #basename, #binread, #children, #chmod, #compare_stream, #dir, #directory?, #each_line, #exclusive_create, #exclusive_open, #executable?, #exist?, #expand_path, #file?, #lstat, #mkpath, #open, #path_string, #pathname, #read, #read_preserve_line_endings, #readlink, #size, #stat, #symlink, #symlink?, #touch, #writable?

Instance Method Details

#replace_file(path, mode = nil, &block) ⇒ Object


14
15
16
17
18
19
20
21
22
# File 'lib/puppet/file_system/jruby.rb', line 14

def replace_file(path, mode = nil, &block)
  # MRI Ruby rename checks if destination is a directory and raises, while
  # JRuby removes the directory and replaces the file.
  if Puppet::FileSystem.directory?(path)
    raise Errno::EISDIR, _("Is a directory: %{directory}") % { directory: path }
  end

  super
end

4
5
6
7
8
9
10
11
12
# File 'lib/puppet/file_system/jruby.rb', line 4

def unlink(*paths)
  File.unlink(*paths)
rescue Errno::ENOENT
  # JRuby raises ENOENT if the path doesn't exist or the parent directory
  # doesn't allow execute/traverse. If it's the former, `stat` will raise
  # ENOENT, if it's the later, it'll raise EACCES
  # See https://github.com/jruby/jruby/issues/5617
  stat(*paths)
end