[Gambas-user] Pb instanciating inotify watch

T Lee Davidson t.lee.davidson at gmail.com
Thu Mar 7 00:44:15 CET 2019


That actually wasn't my example. It was a very quick modification of an outdated example. I did not test it for proper operation 
since I figured it would be enough to get the OP started.

Thank you for the correction. I have deleted the commented lines in the Wiki example to avoid confusion.


___
Lee


On 3/6/19 6:28 PM, Matthew Collins wrote:
> 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 <mailto: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 ]----
> 
> 
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
> 


More information about the User mailing list