in reply to filesystems & Perl
Hi harangzsolt33,
I'm not sure how Perl implements readdir internally, but if POSIX.1-2008 is anything to go by:
... files may be removed from a directory or added to a directory asynchronously to the operation of readdir(). ... If a file is removed from or added to the directory after the most recent call to opendir() or rewinddir(), whether a subsequent call to readdir() returns an entry for that file is unspecified.
Although I suspect the behavior would vary between operating systems and file systems, I would be surprised if files that have not been added or deleted were skipped by readdir.
However, I am wondering why this is important to you? Have you discovered a case where a file is not being reported by readdir, or are you experiencing some other kind of trouble? Are you, for example, copying files from one place to another and are worried that some might be missed?
Update: This article on Mac OS X says that on HFS, unlinking files while using readdir() may cause some files to be skipped. If you want to delete all files in a directory, the suggestion is to use rewinddir until all files have been unlinked. Update 2: ... and if you look at rewinddir in perlport, you'll see that method won't work on Win32.
On the other hand, search for "readdir" in "The Linux Programming Interface" and on page 354 you'll see the mention that files that have not been added or deleted are guaranteed to be returned.
So again, in order to find the best solution, I think you need to describe the problem you're trying to solve some more.
Regards,
-- Hauke D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: filesystems & Perl (updated!)
by harangzsolt33 (Deacon) on Aug 13, 2016 at 03:21 UTC | |
by hippo (Archbishop) on Aug 13, 2016 at 09:26 UTC | |
by haukex (Archbishop) on Aug 13, 2016 at 09:50 UTC | |
by FreeBeerReekingMonk (Deacon) on Aug 13, 2016 at 19:34 UTC |