• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Knowing file system changes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Knowing file system changes?


  • Subject: Re: Knowing file system changes?
  • From: Andreas Schwarz <email@hidden>
  • Date: Sun, 14 Apr 2002 19:51:09 -0700

Sorry to come so late to this thread (these things move so fast if you forget to read for a day it's already over!).

Is it possible to know, using Cocoa or C, when a change, such as creation or
copying or moving or renaming of a file, occurs in the file system? If so
how?

I had a similar question many months back. At the time, I couldn't find a particularly nice solution (the FNNotify() and related functions that David Remahl mentioned were brought up to me, but I didn't like them for some reasons or other that I cannot remember now; possibly the limitations David mentions an the lack of a nice Objective-C wrapper for it).

As a result I went off and rolled my own from scratch; I don't have a whole lot of experience so it may not be the nicest thing anyone has ever seen, but it works for me (I use it in my app gBrowser and it seems to work wonderfully). I've always meant to post it for others to check out, since I'm sure there are a lot of better programmers out there who could improve on it (assuming they want to ;-).

So here it is:
http://homepage.mac.com/schwarz/AASFilesystemChecker/

The files are commented fairly well, but I intend to write some better documentation soon. Perhaps later today, but I do not have time at the moment. I hope it is of some use to someone!

It is based on a subscription-type mechanism (so no, you can't really ust ask for notifications of changes anywhere in the filesystem; you must subscribe to individual folders; sorry if that's not what you wanted :-\). In normal usage it seems to be very low on CPU usage (~1% for a brief moment every time it checks the filesystem on my G4 450); it checks the filesystem periodically (which you can specify; I have it set to every 2.5 seconds when my app is in the foreground and 5 seconds when it is in the background, and pause it when the app is hidden) or when you ask it to manually. It reports when files have been moved, renamed, updated (the mod date changed but not the path), or deleted, and gives you both the old path to the file and the new path.

Again, I hope this is of some use to at least one other person out there... and if anyone has any ideas for improvement, please say :-).

Andreas Schwarz
http://homepage.mac.com/schwarz
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Gaining temporary access to copy files to the library folder...
  • Next by Date: Re: Using Terminal to set folder icons
  • Previous by thread: Re: Knowing file system changes?
  • Next by thread: Re: Resizing NSToolbarItems?
  • Index(es):
    • Date
    • Thread