[Gambas-user] Pb instanciating inotify watch
Matthew Collins
matthew.charles.collins.75 at gmail.com
Thu Mar 7 00:28:27 CET 2019
Your example only notifies on delete and not create (the last event set)...
Please try out this new runnable example in the wiki:
http://gambaswiki.org/wiki/comp/gb.inotify/watch
Matt
> On 2 Mar 2019, at 19:33, T Lee Davidson <t.lee.davidson at gmail.com> wrote:
>
>> On 3/2/19 2:22 PM, Tobias Boege wrote:
>> [snip]
>> Indeed, the classes were renamed later, and possibly redesigned
>> (I don't remember, but let's see):
>>> But when I want to run his code:
>>>
>>> Dim hWatch As New Watch ("/tmp/gambas." & Str$(User.Id), True, 0) As
>>> "GambasDirectory"
>>>
>>> I get an error "too many arguments" ("trop d'arguments" my installation
>>> being in French).
>>>
>>> Which syntax should be correct?
>>>
>> According to the documentation [1] this is the correct signature and
>> the source code agrees. You should see (or be able to find in the
>> "Debugging" tab of the panel on the bottom of the Gambas IDE window)
>> a stack trace when an error happens. Is the error raised in your code
>> or does the stack trace indicate that comes from *inside* gb.inotify?
> [snip]
>
> Indeed, the classes were redesigned. The 'too many arguments' error is caused by the parameters in the event handler's (Create, Delete) signatures.
>
> The example needs a little reworking:
>
> ' Gambas module file
>
> Public Sub Main()
> ' Disable all unneeded events to increase performance
> Dim hWatch As New Watch("/tmp/gambas." & Str$(User.Id), True, 0) As "GambasDirectory"
>
> ' Capture creation and deletion of files or directories
> hWatch.Events[Watch.Create] = True
> hWatch.Events[Watch.Delete] = True
> Print "I'm watching... You may now start Gambas projects."
> End
>
> Public Sub GambasDirectory_Create()
> If Not Watch.IsDir Then Return
> Print "New directory for Gambas process";; Watch.Name;; " - ";;
> With Split(File.Load("/proc" &/ Watch.Name &/ "cmdline"), "/")
> Print "which is";; Left$(.[.Max], -1)
> End With
> End
>
> Public Sub GambasDirectory_Delete()
> If Not Watch.IsDir Then Return
> ' The directory in /proc/ may be removed at this time so we can't
> ' get any more information.
> Print "Gambas process";; Watch.Name;; "terminated (normally)"
> End
>
>
> ___
> Lee
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190306/60fdb7f0/attachment.html>
More information about the User
mailing list