Add File.readlink?#16004
Conversation
| if bytesize == -1 | ||
| if Errno.value.in?(Errno::EINVAL, Errno::ENOENT, Errno::ENOTDIR) | ||
| yield | ||
| end |
There was a problem hiding this comment.
Suggestion (non blocking): we could simplify and boost the implementation if buf was a StaticArray(UInt8, 4096), no need for the loop and no need to allocate Bytes, only the final String.
There was a problem hiding this comment.
Let's move that to a follow-up.
Co-authored-by: Julien Portalier <julien@portalier.com>
|
This caused an async merge conflict with #16002 which inadvertedly called |
…16022) Fixes a regression caused by simultaneous changes to the same code in #16004 and #16002 (#16004 (comment)). The call was never supposed to go to `File.readlink` (i.e. `Crystal::System::File.readlink`) but the public method `::File.readlink`. Now with `::File.readlink?` available from #16004, we can use that directly.
File.readlink?is a non-raising alternative toFile.readlinkwhich returnsnilif the file doesn't exist or is not a symlink.