Fastest way to check for new files in a folder
Fastest way to check for new files in a folder
- Subject: Fastest way to check for new files in a folder
- From: Rick Hoge <email@hidden>
- Date: Mon, 15 Jan 2007 00:25:25 -0500
I have an app that needs to poll for new files in a folder that may a
large number of files (i.e. thousands).
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.
Thanks for any suggestions -
Rick
_______________________________________________
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