Professional Web Applications Themes

File change notification - Mac Programming

Hi all, I'm trying to get notified when a file changes in an external editor. The typical scenario is the following: - my app tells Photoshop to open the file (this works fine) - when the file is saved in Photoshop, I need to be notified I was hoping that NSWorkspaceDidPerformFileOperationNotification would do the job. Unfortunately, it seems this notification is sent only when the app itself is doing the file operation. So I tried using FNSubscribe. FNSubscribe watches folders. Works fine, BUT I get called only for creation/deletions/renames, not for updates (I definitely NEED this) Is there an official ...

  1. #1

    Default File change notification

    Hi all,

    I'm trying to get notified when a file changes in an external editor. The
    typical scenario is the following:
    - my app tells Photoshop to open the file (this works fine)
    - when the file is saved in Photoshop, I need to be notified

    I was hoping that NSWorkspaceDidPerformFileOperationNotification would do
    the job. Unfortunately, it seems this notification is sent only when the app
    itself is doing the file operation.

    So I tried using FNSubscribe. FNSubscribe watches folders. Works fine, BUT I
    get called only for creation/deletions/renames, not for updates (I
    definitely NEED this)

    Is there an official way to watch for file changes ? Can it be done at the
    BSD level ? I'd really hate to use a timer to poll the info.

    Eric

    Eric Guest

  2. #2

    Default Re: File change notification

    In article <BBD97C46.1552B%fr>,
    Eric VERGNAUD <fr> wrote:
     
    I believe you want to do "man kqueue" (requires Mac OS X 10.3)

    Reinder
    Reinder Guest

  3. #3

    Default Re: File change notification

    In article <BBD97C46.1552B%fr>,
    Eric VERGNAUD <fr> wrote:
     

    On Panther, see man 3 notify.

    Hope this helps,
    Eric

    --
    Eric Albert edu
    http://rescomp.stanford.edu/~ejalbert/
    Eric Guest

  4. #4

    Default Re: File change notification

    dans l'article wxs.nl, Reinder
    Verlinde à invalid a écrit le 13/11/03 19:14:
     
    > I believe you want to do "man kqueue" (requires Mac OS X 10.3)
    >
    > Reinder[/ref]

    Thanks, but 10.3 only is not acceptable. Also I read that:

    "It is currently not possible to watch a vnode(9) that resides on anything
    but a UFS file system. "

    Do you know if this is true for Apple's BSD ?

    Eric

    Eric Guest

  5. #5

    Default Re: File change notification

    dans l'article stanford.edu, Eric Albert
    à edu a écrit le 13/11/03 19:17:
     
    >
    > On Panther, see man 3 notify.
    >
    > Hope this helps,
    > Eric[/ref]

    Thanks but notify is only available starting from 10.3.

    Eric

    Eric Guest

  6. #6

    Default Re: File change notification

    In article <BBD99DF9.1555C%fr>,
    Eric VERGNAUD <fr> wrote:
     
    > >
    > > On Panther, see man 3 notify.[/ref][/ref]
     

    Yep. It's a new feature. I'd suggest polling infrequently on older
    systems and using notify(3) on 10.3 or later.

    -Eric

    --
    Eric Albert edu
    http://rescomp.stanford.edu/~ejalbert/
    Eric Guest

  7. #7

    Default Re: File change notification

    In article <BBD99DDB.1555B%fr>,
    Eric VERGNAUD <fr> wrote:
     
    > > I believe you want to do "man kqueue" (requires Mac OS X 10.3)
    > >
    > > Reinder[/ref]
    >
    > Thanks, but 10.3 only is not acceptable. Also I read that:
    >
    > "It is currently not possible to watch a vnode(9) that resides on anything
    > but a UFS file system. "
    >
    > Do you know if this is true for Apple's BSD ?[/ref]

    That line isn't part of the kqueue(2) man page on Panther. Where did
    you find it?

    -Eric

    --
    Eric Albert edu
    http://rescomp.stanford.edu/~ejalbert/
    Eric Guest

  8. #8

    Default Re: File change notification

    dans l'article stanford.edu, Eric Albert
    à edu a écrit le 14/11/03 5:36:
     
    >
    > That line isn't part of the kqueue(2) man page on Panther. Where did
    > you find it?[/ref]

    On the web, didn't note the link though.

    Eric

    Eric Guest

  9. #9

    Default Re: File change notification

    Eric VERGNAUD wrote: 
    >>
    >>That line isn't part of the kqueue(2) man page on Panther. Where did
    >>you find it?[/ref]
    >
    >
    > On the web, didn't note the link though.[/ref]

    Looks like its part of the kqueue(2) man page on FreeBSD. Whether kqueue
    differs between Panther and FreeBSD I will leave as an exercise to the
    reader.

    <http://www.google.com/search?q=It+is+currently+not+possible+to+watch+a+v node%289%29+that+resides+on+anything+but+a+UFS+fil e+system.&ie=ISO-8859-1&hl=xx-elmer&btnG=Google+Seawch>


    --

    Patrick

    ----------------------------------------------------------------------

    Patrick Guest

  10. #10

    Default Re: File change notification

    Hi all,

    I've digged a little into kqueue and it seems you need to run it in a
    separate thread if you don't wan't kevent to block your app flow.

    The MacOS notification seems lighter, because it does not require a thread.

    Is there a way to use kqueue and kevent without creating a thread ?

    By the way, anyone knows a good book on BSD programming. Man is really not
    useful to start with, and I couldn't find very attractive doentation on
    the web.

    Eric

    Eric Guest

  11. #11

    Default Re: File change notification

    In article <BBD99DDB.1555B%fr>,
    Eric VERGNAUD <fr> wrote:
     

    Almost every Mac OS X user will have their boot disk formatted
    in HFS+, not UFS format. Sorry, but watching vnodes using
    kqueue is not going to work for most users.


    Simon Guest

  12. #12

    Default Re: File change notification

    In article <0.1.2>, Simon Slavin wrote: 
    >
    > Almost every Mac OS X user will have their boot disk formatted
    > in HFS+, not UFS format. Sorry, but watching vnodes using
    > kqueue is not going to work for most users.[/ref]

    Luckily, kqueue does indeed work with HFS+ on OS X (the UFS only
    limitation *was* from a FreeBSD doent rather than an Apple one).

    http://www.logicalshift.demon.co.uk/kqueue.c contains a short test
    application that demonstrates this (watches the currently selected
    directory for changes). Works like a charm on HFS+ volumes.

    Andrew.
    Andrew Guest

  13. #13

    Default Re: File change notification

    dans l'article logicalshift.demon.co.uk, Andrew
    Hunter à demon.co.uk a écrit le 16/11/03 1:59:
     

    Andrew,

    Thanks very much for pointing me to this sample.

    Eric

    Eric Guest

  14. #14

    Default Re: File change notification

    In article <logicalshift.demon.co.uk>,
    Andrew Hunter <demon.co.uk> wrote:
     
    >
    >Luckily, kqueue does indeed work with HFS+ on OS X (the UFS only
    >limitation *was* from a FreeBSD doent rather than an Apple one).[/ref]

    Hey, cool. Apologies for the wrong information. Thanks for
    correcting it.


    Simon Guest

Similar Threads

  1. Form change notification
    By artacus in forum Macromedia Flex General Discussion
    Replies: 2
    Last Post: April 16th, 12:31 AM
  2. Directory-change notification on Solaris
    By Fabio in forum UNIX Programming
    Replies: 10
    Last Post: October 3rd, 06:32 PM
  3. Change Notification functions in Darwin?
    By Dylan in forum Mac Programming
    Replies: 4
    Last Post: September 27th, 07:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139