Lazarus
Programming => General => Topic started by: superc on January 02, 2019, 02:39:00 pm
-
Hello,
I must receive a notification in my program when a specific file into a specific directory is changed;
the program can run in both Windows and Raspbian (raspberry) and can receive data in a specific directory and append data in only one static file.
I have seen a document of Michaƫl Van Canneyt "Displaying and Watching directories using Lazarus" and it's of 2011 and my question is what is the best method in 2018/2019 for
implementing in a cross-platform application for watching file in Lazarus?
Thanks in advance.
-
I have never used it but this checks every second the file size/date.
https://github.com/Alexey-T/ATFileNotif-Lazarus
On windows there are better ways to do it but at least this should be cross-platfom since only basic operations are used.
-
Mhhh, it use a ttimer for check .... Of the series: if you do not have anything better you go to sleep with your wife.
-
@superc
Let's see, if the 'Double Commander' knows more than Wives: https://sourceforge.net/p/doublecmd/wiki/Download/ (https://sourceforge.net/p/doublecmd/wiki/Download/)
-> Download the Source and take a Look at 'src\platform\uDriveWatcher.pas'
I'm just writing a simple FileBrowser to manage Audio-/VideoFiles, but didn't check that Unit yet - maybe it's what You're Looking for.
:)
-
Hi, i use this, see attachment, Windows only.
-
sstvmaster, I think I asked you this before?
What does the SSTV-Master mean? Slow Scan Tv comes to mind. :D
-
@jamie, thats right.
-
https://forum.lazarus.freepascal.org/index.php?topic=37415.0 (https://forum.lazarus.freepascal.org/index.php?topic=37415.0)
-
this is the link to the unit metis recommended
https://github.com/cooljeanius/doublecmd/blob/master/src/platform/udrivewatcher.pas
this should fit for you
-
@mercurhyo
wow, is perfect !
Thanks :D
-
From what I can see that only monitors a Device change, which means It only notifies you of a
a drive being inserted ect. It does not watch a file in a specific path..
-
I'm quite sure, the 'Double Commander' does anything You want with Drives, Dirs and Files.
Simply download the Binary and check out the running App.
Then take the (whole) Source and see how it's done - it's all open Source :)
-
For windows you need to use "FindFirstChangeNotification", then FindNextChangeNotification
and finally the FindCloseChangeNotification to end it,
basically you specify the file you watch to watch or Directory etc...
this is a blocking process so you do need to so this within a thread...
-
@superc
:D :P ;)
-
feel free to thank @Wosi who made excellent crossplatform work O:-) with a cool API to watch files'n'dirs
-
raspberry = linux
https://www.freepascal.org/docs-html/rtl/linux/inotify_add_watch.html