Skip to content
New issue

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

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

Already on GitHub? # to your account

Sanitize File\exists? + add missing stdlib function #1570

Merged
merged 10 commits into from
Feb 19, 2024

Conversation

drkameleon
Copy link
Collaborator

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:

  • 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

  • Enhancement (implementation update, or general performance enhancements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (documentation-related additions)

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@drkameleon drkameleon added enhancement New feature or request library Issues related to the standard library new feature New feature/addition labels Feb 17, 2024
@github-actions github-actions bot removed the library Issues related to the standard library label Feb 17, 2024
@github-actions github-actions bot added the library Issues related to the standard library label Feb 17, 2024
@github-actions github-actions bot added the unit-test Unit tests label Feb 17, 2024
@drkameleon
Copy link
Collaborator Author

Ready to merge! 🚀

@drkameleon drkameleon merged commit 00dca7f into master Feb 19, 2024
12 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request library Issues related to the standard library new feature New feature/addition unit-test Unit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant