Re: Stdio.File()->notify
Pontus Östlund <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CAAyMhKw-5xLHKpqGXpSuRuLeH3UHO_Ge_E7uVsDESQD3ST03dw@mail.gmail.com> |
Ok, I misunderstood you. I was talking about Inotify. You're probably correct. I deleted the file via Nautilus which would put it in the thrash bin. One thing though: System.Inotify doesn't seem to work recursively on a directory. I don't know the internals of inotify and if it's also meant to watch all subdirectories. In my case i could create a wrapper that creates a watcher for all subdirectories as well, and maybe that's the way you have to do it? # Pontus 2014-09-23 15:33 GMT+02:00 Arne Goedeke <[email protected]>: > I was talking about Stdio.File()->notify(). > > Did you remove the file using rm, or possibly with some graphical > interface? linux desktops tend to not actually remove files, but rather > move them to some kind of trashbin directory. That might explain the > missing event. > > arne > > > On Tue, 23 Sep 2014, Pontus Ã~Vstlund wrote: > > We'll it seems to be working good enough for my purpose though. >> >> For instance when a file is renamed (the callback is called twice): >> >> Mask: 64=IN_MOVED_FROM, Cookie: 48952, File: /home/ponost/src/ >> poppa.github.io/_site/oldname.pike >> Mask: 128=IN_MOVED_TO, Cookie: 48952, File: /home/ponost/src/ >> poppa.github.io/_site/newname.pike >> >> One thing that doesn't seem to work is IN_DELETE. The only callback you >> get >> is IN_MOVED_FROM but you don't get a IN_DELETE after that, which would >> make >> it hard to determine if the file is about to be moved or deleted. >> >> But in this particular case I'm not so interested in what happened, just >> that something happened. >> >> # Pontus >> >> >> 2014-09-23 14:40 GMT+02:00 Arne Goedeke <[email protected]>: >> >> Its about time it gets into stable pike releases, considering that >>> inotify was added to the linux kernel in 2005. >>> >>> I am not sure how the notify() API is supposed to be used. I think it >>> never really got finished. Anyway, as it currently exists, its not >>> usable. Even when setting up the signal handler correctly, I don't see a >>> way to decide which file object actually corresponds to the file >>> descriptor which triggered the event. >>> >>> Arne >>> >>> On Tue, 23 Sep 2014, Pontus 脋Vstlund wrote: >>> >>> Cool! I guess Inotify is a fairly recent addition to Pike so I had to >>> pull >>> >>>> down Pike 8, but I got it working after that. >>>> >>>> Thanks a bunch! :) >>>> >>>> # Pontus >>>> >>>> 2014-09-23 11:20 GMT+02:00 Arne Goedeke <[email protected]>: >>>> >>>> The second argument (a callback) is not actually used by the notify() >>>> >>>>> code. Instead, you would need to add a signal handler. I would suggest >>>>> using System.Inotify, it should work as documented and is much more >>>>> flexible. >>>>> >>>>> So, no, you are not doing anything wrong. notify() is not documented >>>>> correctly and should probably be removed completely. >>>>> >>>>> Arne >>>>> >>>>> >>>>> On Tue, 23 Sep 2014, Pontus 鐛竀stlund wrote: >>>>> >>>>> Hello! >>>>> >>>>> >>>>>> I have a question about the notify method in Stdio.File which I can't >>>>>> get >>>>>> to work. Maybe I'm using it wrong or maybe it just doesn't work, I >>>>>> don't >>>>>> know. >>>>>> >>>>>> I'd like to listen for changes in a directory: >>>>>> >>>>>> Stdio.File dir = Stdio.File("/my/dir"); >>>>>> dir->notify( >>>>>> Stdio.DN_MULTISHOT | >>>>>> Stdio.DN_MODIFY | >>>>>> Stdio.DN_CREATE | >>>>>> Stdio.DN_DELETE | >>>>>> Stdio.DN_RENAME, >>>>>> lambda() { >>>>>> werror("Hello\n"); >>>>>> } >>>>>> ); >>>>>> >>>>>> but nothing seems to happen. Am I doing something wrong? >>>>>> >>>>>> And yes, I'm using Linux. >>>>>> >>>>>> Regards >>>>>> # Pontus >>>>>> >>>>>> >>>>>> >>>>>