-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 check for regular files in os.walkDir
and os.getFileInfo
(Unix-specific)
#20448
Comments
"Regular file" is kinda blurry in Linux IMHO, maybe check how other langs do it (?), |
I mean just superficial check, i.e. check
But anyway it's up to filesystem writers to ensure any sane semantics. |
Well we mean "real" file by it. A thing that is stored persistently on a physical device, not UNIX's ridiculously broken bullshit excuse for "we don't understand programming, automation or how to expose sane APIs". |
I suppose it was implemented by #20628, feel free to reopen it. |
* Implement Unix file regularity check * update std/dirs also
* Implement Unix file regularity check * update std/dirs also
Summary
For nearly all applications we should distinguish regular files and special Unix files.
It's because reading from things like Unix FIFO (named pipe) may hang an application, reading device files may lead to side effects, etc.
For example, after running
mkfifo <name>
in a directory,nimgrep
hangs there because of attempting to read it and not getting any data from FIFO.Description
The proposal is
isRegular
field toFileInfo
object returned byos.getFileInfo
. For normal directories and files it will betrue
; for Unix FIFOs, Unix domain sockets, device files, etc it will befalse
.onlyRegular
parameter to iteratoros.walkDir
. By defaultonlyRegular=false
. WhenonlyRegular=true
, only regular files will be yielded by the iterator.Note that there is no performance penalty as necessary info is already returned by
stat/lstat
andreaddir
syscalls.Alternatives
No response
Standard Output Examples
No response
Backwards Compatibility
This feature is backward compatible.
Links
No response
The text was updated successfully, but these errors were encountered: