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

readdir: default to "." or pwd() depending on join keyword #33175

Merged
merged 1 commit into from
Sep 7, 2019

Conversation

StefanKarpinski
Copy link
Sponsor Member

@StefanKarpinski StefanKarpinski commented Sep 5, 2019

This is a pretty niche issue but it allows readdir() to work after the current working direcotory has been deleted, whereas when join=true you need a path which no longer exists, so pwd() fails and therefore readdir(join=true) also fails.

I can't find a way to get a current working directory that is both deleted and non-empty:

  • if you create files first, then you can't delete the directory (unless you use rm -r in which case it deletes the file before deleting the directory)
  • trying to create files after deleting the directory doesn't work either since all the ways I tried of creating files in a deleted directory failed.

base/file.jl Show resolved Hide resolved
test/file.jl Outdated
@test !ispath(d)
@test isempty(readdir())
@test_throws SystemError readdir(d)
@test_throws Base.IOError readdir(join=true)
Copy link
Sponsor Member Author

@StefanKarpinski StefanKarpinski Sep 5, 2019

Choose a reason for hiding this comment

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

It's kind of nasty that these throw different errors: the SystemError comes from trying to call readdir on a non-existend directory whereas the Base.IOError comes from trying to do pwd() in a deleted directory.

@StefanKarpinski
Copy link
Sponsor Member Author

What is going on with the tests? The failures do not seem related to this change.

This is a pretty niche issue but it allows `readdir()` to work after the current
working direcotory has been deleted, whereas when `join=true` you need a path
which no longer exists, so `pwd()` fails and so `readdir(join=true)` also fails.
@StefanKarpinski
Copy link
Sponsor Member Author

I don't see how this Win32 failure could be caused by this change, but I don't want to merge this and break Win32. Anyone know if this is a thing that's been happening otherwise?

@StefanKarpinski StefanKarpinski merged commit 3424d2c into master Sep 7, 2019
@delete-merged-branch delete-merged-branch bot deleted the sk/readdir branch September 7, 2019 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants