I'm using Crystal 0.25.0 and File.info(string).symlink?
returns false when it should return true in the following sample:
`mkdir -p /tmp/delete`
Dir.cd "/tmp/delete"
`rm -f b`
`touch a`
`ln -s a b`
puts File.info("b").symlink?.inspect # false
puts File.info("b").type # File
puts Process.run("test", "-L b".split).success? # true
puts Process.run("test", "-L a".split).success? # false
It seems to resolve the link. Is this the expected behaviour?
Yes, File.info
follows symlinks by default. This is the expected behavior, but you can disable it by passing follow_symlinks: false
to the method:
File.info("b", follow_symlinks: false).symlink? # => true
This behavior is documented under File.info
in the API docs.