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

Add method to check if a given path is a directory #259

Closed
Jason2605 opened this issue Sep 18, 2020 · 9 comments
Closed

Add method to check if a given path is a directory #259

Jason2605 opened this issue Sep 18, 2020 · 9 comments
Assignees
Labels
feature request Discussion about a new feature

Comments

@Jason2605
Copy link
Member

Summary

Similar to #257, there is no way to determine whether a given path is a directory or not. I propose adding an isdir method to the Path library.

@Jason2605 Jason2605 added enhancement Implementation of a new feature Hacktoberfest feature request Discussion about a new feature and removed enhancement Implementation of a new feature labels Sep 18, 2020
@artorias111
Copy link
Contributor

Hey! I'd like to try this.
https://stackoverflow.com/questions/4553012/checking-if-a-file-is-a-directory-or-just-a-file
According to this, there's a way to add the S_ISREG() macro to check if the path points to a directory, can I try and implement this?

@Jason2605
Copy link
Member Author

Thanks for the initial activity on the repo and for wanting to contribute, means a lot 😃

Note S_ISREG() will check if it's a regular file rather than a directory, S_ISDIR() will check if it's a directory! It would be worth looking into a similar version for windows, but for the time being i'm happy for you to crack on using the above macro.

I'll assign this ticket to you, and questions let me know!

@artorias111
Copy link
Contributor

artorias111 commented Oct 1, 2020

Hi!
I started off with editing the path.c file in Dictu/c/optionals/
by adding a isdir() function. However, when I try building it using make dictu, I get an error message

‘isdir’ defined but not used [-Werror=unused-function]

I'm a bit confused about which other file needs to be edited other than the path.c file, will keep looking in the meantime!

@Jason2605
Copy link
Member Author

You will also need to register it within the module at the bottom of the file, see here for some examples!

@artorias111
Copy link
Contributor

Oh alright got it, thanks!

@artorias111
Copy link
Contributor

artorias111 commented Oct 1, 2020

Hey! So I made the changes in path.c, works well with Linux directories (tested on Ubuntu).
Should I add tests in the tests directory?
Also, should I add anything to the docs directory?

@Jason2605
Copy link
Member Author

Yeah! Add a new test file relating to the new method you've created here, add the import for the new file here. And then finally add a couple of notes about it in the documentation here!

@artorias111
Copy link
Contributor

Hey! Made changes to the files as you told. Could you check the pr and let me know if it's okay?

@Jason2605
Copy link
Member Author

The PR was great, thank you very much!

Resolved as part of #269

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Discussion about a new feature
Projects
None yet
Development

No branches or pull requests

2 participants