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

File system and directory access #100

Open
jacobwilliams opened this issue Nov 24, 2019 · 2 comments
Open

File system and directory access #100

jacobwilliams opened this issue Nov 24, 2019 · 2 comments
Labels
Clause 16 Standard Clause 16: Intrinsic procedures and modules

Comments

@jacobwilliams
Copy link

I've always considered it a major defect of Fortran that it doesn't seem to know anything about directories or the file system. I think some people consider this a feature of sorts, but it's hard to imagine nowadays any complicated program that doesn't need to know about these things. So we all resort to compiler extensions (e.g. Intel's portability library is great) or hand-rolled hacks or platform-specific system calls. It would be nice if a lot of this was standardized. Just of few of the things we need:

  • does a directory exist? (I think Intel has an extension for this).
  • delete a file or directory (I know for files we can open and then close(..status='delete') but that is just so non-modern).
  • create a directory
  • list all the files in a directory
  • get/set the current working directory
  • rename a file or directory
  • ... others?

Having these standardized so they will work on all platforms and with all compilers would be a big improvement over the current situation.

@certik
Copy link
Member

certik commented Jan 7, 2020

This should all become part of stdlib.

@certik certik added the Clause 16 Standard Clause 16: Intrinsic procedures and modules label Apr 23, 2022
@marshallward
Copy link
Contributor

marshallward commented Jul 21, 2023

I think that the first bullet point here deserves to be considered as a language feature, rather than something to be implemented in stdlib.

As far as I know, there is no way to detect directories. inquire(file=...) works in GNU and a few other compilers, but not in Intel. inquire(directory=...) works for Intel, but directory is a non-standard extension. I don't know of any other alternatives.

I don't really see how this can be solved in stdlib without going through C interfaces to stat.

At minimum, I think that directory= or dir= or whatever could be introduced as a standard argument to inquire, and indicate invalid results if the filesystem happens to not support directories.

Or maybe there is some way to have file= work for directories without breaking precedent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clause 16 Standard Clause 16: Intrinsic procedures and modules
Projects
None yet
Development

No branches or pull requests

3 participants