[Gambas-user] Pb instanciating inotify watch
T Lee Davidson
t.lee.davidson at gmail.com
Sat Mar 2 20:33:34 CET 2019
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
More information about the User
mailing list