[Gambas-user] Watch inotify

Tobias Boege taboege at gmail.com
Thu Jun 28 16:54:17 CEST 2018


On Thu, 28 Jun 2018, Mayost Sharon wrote:
> Hello
> 
> 
> ' Gambas module file
> 
> Public hWatch As Watch
> 
> Public Sub Main()
> 
>   hWatch = New Watch("/home/sharon/", True, -1) As "sharon"
> 
> End
> 
> Public Sub sharon_Open()
>   
>   Print "open file"
> End
> 
> 
> How can I know the name of the file that caused the event
> 

The Watch class has a bunch of static properties which, during
events, are magically filled with the relevant information.
To get the name of the file use

  Public Sub sharon_Open()
    Print "open file";; Watch.Name
  End

This is also mentioned in the docs [1] (perhaps not clear enough?):

  The static properties are used to store data from the kernel during
  event management. Use them only in event handlers.

[ I'm actually not sure why I did that. Static properties for event
data are a common thing in Gambas (think Mouse.X or Highlight.Text
in gb.qt4.ext) but I could as well have used dynamic properties of
the Watch *object* which is stored Last, for better encapsulation. ]

Regards,
Tobi

[1] http://gambaswiki.org/wiki/comp/gb.inotify/watch

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list