You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Windows, as on Unix, you can create "dangling" symlinks, i.e. symlinks where the target does not exist.
However, with JRuby you cannot delete a dangling link on Windows. Instead it raises an Errno::ENOENT. You will need the ffi gem to test/verify this:
# symlink.rb
require 'ffi'
class Windows
extend FFI::Library
ffi_lib :kernel32
attach_function :CreateSymbolicLinkA, [:string, :string, :ulong], :bool
def self.symlink(old_name, new_name)
# Flip the arguments to match File.symlink
unless CreateSymbolicLinkA(new_name, old_name, 0) # Assume file
raise SystemCallError.new('CreateSymbolicLink', FFI.errno)
end
end
end
# Please run with elevated privileges.
# Here assume 'bogus.txt' does not exist
Windows.symlink('bogus.txt', 'test_link.txt')
File.delete('test_link.txt') # Works with MRI, fails with JRuby.
The text was updated successfully, but these errors were encountered:
On Windows, as on Unix, you can create "dangling" symlinks, i.e. symlinks where the target does not exist.
However, with JRuby you cannot delete a dangling link on Windows. Instead it raises an Errno::ENOENT. You will need the ffi gem to test/verify this:
The text was updated successfully, but these errors were encountered: