Lazarus
Programming => Operating Systems => Windows => Topic started by: sblisesivdin on March 23, 2020, 11:36:31 am
-
Hello dear all,
I am trying to write a small program controlling my scientific calculations. I can add, copy remove files and folders with controlling many things. However, I need to control a folder with files and when any of the files are not accessed (mostly accessed for writing) for a while (for example 30mins) I want to move the files to another folder.
The thing is how can I filter the folder for inactivity?
-
@sblisesivdin
Create a hash list with all the files in the folder, when a particular file changes the hash will also change. All you have to do is compare two hash lists from time to time. Use the TFPHashList from contnrs.
-
Thank you for this very good idea. I stuck with classical folder operations and this is what I am searching for.
-
sblisesivdin, I note you say "mostly accessed for writing", if that "mostly" means you also need to be aware of another process reading, its a bit hard. Reading won't change the hash for example.
Important question - what operating system are you using ? On linux, you can check the atime of all the files, would be a very fast process, that would tell you if the files had been written to or read. On almost all systems, atime is enabled by default. I expect (but don't know for sure) that MacOS will also provide atime.
I am no windows expert but I believe NTFS does not offer atime. Almost impossible to tell if the file has been read. I think....
Davo
-
Thank you for this very good idea. I stuck with classical folder operations and this is what I am searching for.
Once a forum user asked for an application which compares two folders, then list the same files. I know it's not exactly what are you after, but is not to different either. Please download and test attached project.
-
Actually, looks like I am wrong, NTFS does have an atime attribute now.
Reading that attribute would be a lot faster than reading all of all the files to generate a hash.
Davo
-
Hello dear all,
I am trying to write a small program controlling my scientific calculations. I can add, copy remove files and folders with controlling many things. However, I need to control a folder with files and when any of the files are not accessed (mostly accessed for writing) for a while (for example 30mins) I want to move the files to another folder.
The thing is how can I filter the folder for inactivity?
See Watching a folder for changes with DirWatch (https://forum.lazarus.freepascal.org/index.php/topic,46255.msg334820.html#msg334820).