Skip to content

crunch: other way to detect if a path is a file or a directory#41

Merged
illwieckz merged 1 commit intomasterfrom
illwieckz/file-detection
Feb 22, 2023
Merged

crunch: other way to detect if a path is a file or a directory#41
illwieckz merged 1 commit intomasterfrom
illwieckz/file-detection

Conversation

@illwieckz
Copy link
Member

@illwieckz illwieckz commented Feb 14, 2023

readdir() doesn't support file detection on all file systems, so we use stat() as a fallback.

This makes the crunch tool works with files stored over the network on NFS shares on MacOS.

We also report if the current code fails to detect if a path is a file or a directory, just in case some other corner case surfaces.

It fixes:

readdir() doesn't support file detection on all file systems,
so we use stat() as a fallback.

This makes the crunch tool works with files stored over
the network on NFS shares on MacOS.

We also report if the current code fails to detect if a
path is a file or a directory, just in case some other
corner case surfaces.
@illwieckz illwieckz added the bug Something isn't working label Feb 14, 2023
@illwieckz
Copy link
Member Author

illwieckz commented Feb 22, 2023

This looks good enough for me and it works well.

It would be possible to make the code smaller by relying on stat in all cases, but I assume that only calling stat when readdir doesn't provide the required data means we don't do extra IO with stat when readdir is enough (readdir being called for other things in all cases anyway).

When the Filesystem implementation is complete, readdir will only be used, while the code works on less implemented filesystems with an extra stat call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant