Re: Fastest way to check for new files in a folder
Re: Fastest way to check for new files in a folder
- Subject: Re: Fastest way to check for new files in a folder
- From: "Sean McBride" <email@hidden>
- Date: Mon, 15 Jan 2007 10:43:16 -0500
- Organization: Rogue Research
On 2007-01-15 00:25, Rick Hoge said:
>I have been able to poll for new files using an NSTimer that calls a
>method that repeatedly returns the entire folder listing (using
>[[NSFileManager defaultManager] directoryContentsAtPath:[self
>dataPath]]). This works in principle by looking for files that
>weren't in the last listing, but seems inefficient when the folder
>contains 30,000 files (and I have no control over this).
>
>Is there any way to receive a notification when the directory
>contents change which includes only the files added by the change
>event? This would be a much better way to go, but I can't find
>anything in AppKit that does that. Alternately a folder search that
>uses the file creation time to return only those files that were
>created since the last poll might work.
>
>Note that the folder I'm trying to monitor is on a Windows machine
>that my Mac mounts via Samba. The Windows machine is the host for a
>data acquisition system and I can't modify it. I seem to recall that
>Spotlight might be able to index files on a network mounted hard
>drive, but not sure if this will work over Samba. I'm not expecting
>to be able to use Spotlight, but if there are any opportunities I'm
>ignoring it would be great to find out.
Hi Rick!
Alas, kqueue definitely does not work on remote file systems, see:
<http://lists.apple.com/archives/carbon-dev/2005/Nov/msg00812.html>
So you are stuck with polling. (But do file a radar!)
You might get better performance by using the Carbon File Manager, and
the MoreFileX sample code will be useful:
<http://developer.apple.com/samplecode/MoreFilesX/index.html>
Good luck,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden