Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: The "readdir()" fails to detect files created after the call to "opendir()"

by sundialsvc4 (Abbot)
on Jan 20, 2015 at 17:16 UTC ( [id://1113905]=note: print w/replies, xml ) Need Help??


in reply to The "readdir()" fails to detect files created after the call to "opendir()"

“Directories,” and file-systems in general, are unpredictable data structures.   Entries will not appear in any particular order.   Therefore, you must read the entire directory contents list into memory, then sort that list yourself, then work with the sorted list.   If you need to know what has appeared or disappeared, you must likewise do the comparison yourself.

Also, when you are scanning a directory, you should initiate the scan, run it fully to completion, then close it.   Don’t fall asleep with a scan left-open.   The resource that you are using might be limited, and so your process might be exerting an unforseen negative influence on its neighbors.   (And, in the most benign of circumstances, you can easily fail to see files or see files more than once.)

Note that some file metadata, such as most-recent-access timestamps, are not always supported.   They require a large number of disk writes to take place, and for a reason that might be judged to be not worth the effort (or, in the case of a truly read-only filesystem, not possible).   So, they might have been turned-off by the system administrators.

Most operating systems provide a separate API by which you can “watch” a directory to detect what changes have recently been made to it, but these facilities are specific both to the OS-type and to a particular networked file-system.   They might be privileged.   They might be “convenient, but expensive.”

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1113905]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-26 00:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found