in reply to Re: Testing for readdir failure
in thread Testing for readdir failure
First of all, after reading some of the replies, it became clear that I missed making one point: When the readdir fails to deliver the entire contents of the directory, there is NO warning, nor any other message, issued by Perl. Thus, I don't believe that trapping warnings, nor the warnings pragma, will help.
I will try $!, and testing for the value of closedir, as well as testing for a "false" value of readdir (though that wouldn't work for readdir in a scalar context) and report back what I find.
I downloaded IO::Dirent and looked at its C code. I am a complete novice at C, but it looks to me like it uses C's readdir, whose documentation seems to say that it also returns the same thing for both end-of-directory and an error. (There is a different function named readdir_r which can indicate an error, but that's not what IO::Dirent uses.) It occurs to me that the question I'm really trying to answer is: Exactly what does readdir do when it encounters a problem while reading the directory, and does it do anything that the program can recognize?
The suggestion to stat the directory and verify that the link count matches the number of file names returned is a good one, but I can't use it because those two don't always match in the file system I'm concerned with (called AFS).
Finally, as many have pointed out, testing any of this is clearly a problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Testing for readdir failure
by Laurent_R (Canon) on Apr 22, 2013 at 17:53 UTC | |
by Bob Cook (Acolyte) on Apr 23, 2013 at 00:44 UTC | |
by Laurent_R (Canon) on Apr 23, 2013 at 06:19 UTC | |
|
Re^3: Testing for readdir failure
by LanX (Saint) on Apr 23, 2013 at 00:52 UTC | |
by Bob Cook (Acolyte) on Apr 23, 2013 at 02:45 UTC | |
by LanX (Saint) on Apr 23, 2013 at 15:18 UTC |