Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make File.readable? and .writable? follow symlinks on Windows #14514

Conversation

HertzDevil
Copy link
Contributor

This matches the behavior on Unix-like systems. The ability to opt out could be reintroduced as part of #13291.

Note that File.readable? can never return false for an existing file on Windows since the method doesn't respect ACLs, but it does return false for a non-existing file. Hence, this method is now entirely equivalent to File.exists?.

@HertzDevil HertzDevil added kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:files labels Apr 21, 2024
private def self.accessible?(path, *, check_writable)
private def self.accessible?(path, *, check_writable, follow_symlinks)
if follow_symlinks
path = realpath?(path) || return false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: more idiomatic version:

Suggested change
path = realpath?(path) || return false
return false unless path = realpath?(path)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sija I disagree on being more idiomatic. IMO it makes a lot more sense to focus on the assignment and an escape condition. A trailing assignment is very easy to overlook.

@straight-shoota straight-shoota added this to the 1.13.0 milestone Apr 22, 2024
@straight-shoota straight-shoota merged commit 10414fd into crystal-lang:master Apr 23, 2024
60 checks passed
@HertzDevil HertzDevil deleted the feature/file-readable-writable-symlink branch April 23, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:files
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants