c - Selecting a file randomly from a file system -
This question is related.
I need to work on files and directories randomly as a file logic, such as rename, write, read etc. What I was planning to do, was to list all the files and directories along with their paths randomly to choose from this list. But, as the files and directories are created and destroyed in the actual file system, the list should also be updated. I am able to update the list and keep it inadequate in this way and it should also be atom so that the operation can not access any file later that was removed from the previous operation.
Can you suggest that there is a different way of choosing files..to somehow integrate it with the file system ... but how do we know about the files?
Thanks
I'm Michael J. Barber's answer has found something particularly interesting, but due to my dragon ignorance I can not follow it completely
You do not want to try to keep a list of files, when the file system is ok you should be able to correct it from C. Moving from the root directory, selecting a random file from You can choose a random maximum depth, and if you press a regular file on it before or after it, then use it if it is a directory, then repeat the maximum depth. If this is a special file, then maybe it will start.
It should be very quick. Operation should not be nuclear if the file is not there, then you want to do your operation, try again. Should not be too complicated. As you find your target file, you can create the path. It would be easier to directly deal with FS (I think you are at a very low level) and should be easy to implement.
Comments
Post a Comment