Hi guys. I am coming to you today because I am facing a problem with the command from FileUtils to make symbolic link.
I noticed, if I run the same command to make a symlink 2 times, it make a symlink inside the directory targeted.
Let me explain:
I have one directory named TEST, located in /home/me/TEST
I want to make a symlink named SYSTEM to the dir TEST
If I run it again, a symlink named SYSTEM appear in my directory TEST. Why ?
require "file_utils"
FileUtils.ln_s("TEST", "SYSTEM")
require "file_utils"
FileUtils.ln_s("TEST", "SYSTEM")
Because basically, I would like if that symlink is already here, it don’t overcreate anything else
I need to fix that in that code:
def makeLink(path : String, targetPath : String, linkType : Symbol)
begin
case linkType
when :hardLink
FileUtils.ln(path, targetPath)
when :symbolicLink
FileUtils.ln_s(path, targetPath)
when :symbolicLinkByOverwrite
FileUtils.ln_sf(path, targetPath)
else
Ism.exitProgram
end
rescue File::AlreadyExistsError
rescue error
Ism.notifyOfMakeLinkError(path, targetPath, error)
Ism.exitProgram
end
end
But I don’t know how to fix that