emcrisostomo / fswatch

A cross-platform file change monitor with multiple backends: Apple OS X File System Events, *BSD kqueue, Solaris/Illumos File Events Notification, Linux inotify, Microsoft Windows and a stat()-based backend.
https://emcrisostomo.github.io/fswatch/
GNU General Public License v3.0
5.04k stars 328 forks source link

Other possible events? #212

Open sgbotsford opened 6 years ago

sgbotsford commented 6 years ago

Looking at the event flags, there doesn't seem to be one for file open/close events, and at least the Linux ionotify has this capability.

Also, is there any way to retrieve the name or process number of the program that did the opening?

emcrisostomo commented 5 years ago

I'll have a look at inotify's event flags: they may not be all supported and/or updated in the current version.

Also, is there any way to retrieve the name or process number of the program that did the opening?

Nope, at least not portably.

jchook commented 5 years ago

My main use case is "when I save a file, do something".

Currently fsevents does not satisfy this use case very well.

For example, using Atom editor:

Comparing this to inotifywait, I have CLOSE_WRITE firing ONCE on each save.

kuvaldini commented 5 years ago

Hi? Where is the list of all possible events?

kuvaldini commented 5 years ago

Thanks. grep rules

  enum fsw_event_flag
  {
    NoOp = 0,                     /**< No event has occurred. */
    PlatformSpecific = (1 << 0),  /**< Platform-specific placeholder for event type that cannot currently be mapped. */
    Created = (1 << 1),           /**< An object was created. */
    Updated = (1 << 2),           /**< An object was updated. */
    Removed = (1 << 3),           /**< An object was removed. */
    Renamed = (1 << 4),           /**< An object was renamed. */
    OwnerModified = (1 << 5),     /**< The owner of an object was modified. */
    AttributeModified = (1 << 6), /**< The attributes of an object were modified. */
    MovedFrom = (1 << 7),         /**< An object was moved from this location. */
    MovedTo = (1 << 8),           /**< An object was moved to this location. */
    IsFile = (1 << 9),            /**< The object is a file. */
    IsDir = (1 << 10),            /**< The object is a directory. */
    IsSymLink = (1 << 11),        /**< The object is a symbolic link. */
    Link = (1 << 12),             /**< The link count of an object has changed. */
    Overflow = (1 << 13)          /**< The event queue has overflowed. */
  };
nyngwang commented 2 years ago

@jchook Did you solve it? If I was modifying my file (without saving it) some events also got triggered. I just want to catch one event: on-save.

jchook commented 2 years ago

I switched to fsnotify

Edit: there is a CLI called on.