I am trying to find the last file in a huge file system. One way to do this is to go through all the directories - one at a time, read its contents, select the last file, etc.
The obvious downside is that I have to get all the files in a specific directory. I was wondering if there is a βmagicβ call in Python [1] that Unix supports in order to get only the last file in a directory.
[1]. My application is in Python, but if the turnkey solution does not exist in stdlib, suggest alternatives to C (lanuage) using system calls. I am ready to write a C-extension and do the job.
thanks
update . Suppose I have to offer an explanation why a solution like inotify will not work for me. I was just looking for a system call using Python / C that could give me the latest file. Yes, it would be possible to inotify (or similar comprehensive configuration), which controls FS changes, but taking into account a random directory, how can I find the last file, the essence of the matter.
source share