Class: Puppet::FileSystem::JRuby Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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 directory?(path)
    raise Errno::EISDIR, _("Is a directory: %{directory}") % { directory: path }
  end

  super
end

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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