Forum > Third party

Cross platform DirectoryWatcher

<< < (3/4) > >>

edwinyzh:
checked, worked as expected, and I like the fluent sytle API :)

promisetom:
Has anyone created an app using DirectoryWatcher using Forms.
I would like to use it in a graphics based app, not a console.
I tested an issue version using formas and received a "SIGSEGV exception"
Tom

zamronypj:

--- Quote from: hnb on July 02, 2017, 08:36:09 pm ---
--- Quote from: JuhaManninen on July 02, 2017, 08:28:19 pm ---I think this should be placed in FPC's libraries.

--- End quote ---

Fully agree :). Anyway I see that DirectoryWatcher is licensed under MIT so AFAIK can't be added to FPC libraries.

--- End quote ---

According to  https://softwareengineering.stackexchange.com/questions/189633/what-sublicense-actually-means I believe you can sublicense MIT as LGPL but not vice versa as long as you give copyright license and license notice. https://tldrlegal.com/license/mit-license

af0815:

--- Quote from: promisetom on September 14, 2020, 04:30:52 am ---Has anyone created an app using DirectoryWatcher using Forms.
I would like to use it in a graphics based app, not a console.
I tested an issue version using formas and received a "SIGSEGV exception"
Tom

--- End quote ---
Have you used synchronize to make a correct thread change as described in post #6 from wosi. You have to use this in the callback. See also
https://wiki.freepascal.org/Multithreaded_Application_Tutorial
https://www.freepascal.org/~michael/articles/lazthread/lazthread.pdf

The reason is, the forms and other grafic stuff is not thread safe. So you have to use synchronize to bring the operation to the main thread, which can deal with the forms and the other graphical elements.

But it is a good idea to show the program or parts, so other people can see your problem. Because you see your code and the community sees nothing and can only stick in fog.
 

r.lukasiak:
hi everyone.

I've just discovered DirectoryWatcher and trying  demo confirmed it's what I was looking for. The demo is pretty clear but the thing is that I'd need to use it with forms. I read the old answers and I understand I have to take care of synchronization etc,
Could someone  provide with an example of implementing DirectoryWatcher in forms?

thanks in advance!

-----------------------------------------------------------------------------------------
Edited on 13/05/2022:

Following https://github.com/Wosi/DirectoryWatcher "how to use":

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var  Form1: TForm1;  FolderToWatch: String;  WatchSubFolders: Boolean = true; //I need to monitor subfolders, so I set it to 'true'  DirectoryWatcher: IDirectoryWatcher;     procedure TForm1.SpeedButton1Click(Sender: TObject);begin   FolderToWatch := '/my_path';  WatchSubFolders:=true;   DirectoryWatcher := TDirectoryWatcherBuilder                        .New                        .WatchDirectory(FolderToWatch)                        .Recursively(WatchSubFolders)                        .OnChangeTrigger(OnFileEvent)                         .Build;  DirectoryWatcher.Start;  end;
when building, it's saying that OnFileEvent needs more parameters. On the demo app, the problem doesn't occur.
Any clue?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version