Right now, we have exists?, which works in the following way:
exists? "some/path" - will return true if the path exists and points to a file, but false if the path exists but points to a directory or anything else (or: ofc, if the aforementioned path doesn't exist altogether)
exists?.directory "some/path" - will return true if the path exists and point to a directory, but false if the path exists but points to a file or anything else (or: ofc, if the aforementioned path doesn't exist altogether)
Basically, if we want to check if a given path is a directory, we'd have to do exists?.directory - which is correct, although it's not ultra-intuitive.
What this PR is going to do is:
make sure that exists? returns true if the path exists (be it a file, a directory or whatever) and false otherwise
create at least a file? & directory? predicate/function to check if a given path is a file or directory, respectively. (We could perhaps add another symlink? function, since it's a thing and Nim allows us to do this quite easily 😉 )
Type of change
[x] Enhancement (implementation update, or general performance enhancements)
[x] New feature (non-breaking change which adds functionality)
[x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
Description
Right now, we have
exists?
, which works in the following way:exists? "some/path"
- will return true if the path exists and points to a file, but false if the path exists but points to a directory or anything else (or: ofc, if the aforementioned path doesn't exist altogether)exists?.directory "some/path"
- will return true if the path exists and point to a directory, but false if the path exists but points to a file or anything else (or: ofc, if the aforementioned path doesn't exist altogether)That sounds a bit confusing. (See here: https://discord.com/channels/765519132186640445/829324913097048065/1208304920957157386)
Basically, if we want to check if a given path is a directory, we'd have to do
exists?.directory
- which is correct, although it's not ultra-intuitive.What this PR is going to do is:
exists?
returns true if the path exists (be it a file, a directory or whatever) and false otherwisefile?
&directory?
predicate/function to check if a given path is a file or directory, respectively. (We could perhaps add anothersymlink?
function, since it's a thing and Nim allows us to do this quite easily 😉 )Type of change