Best way of identifying duplicate files in Cocoa
Best way of identifying duplicate files in Cocoa
- Subject: Best way of identifying duplicate files in Cocoa
- From: Frank Reiff <email@hidden>
- Date: Fri, 16 Nov 2007 14:25:31 +0100
Hi,
For my latest project, I need to be able to check whether the files
(or file bundles) at two paths are duplicates (= have the same
content) or not.
While this would be ridiculously easy to do on a plain Unix system, it
turns out to be a major undertaking on OS X.
* file bundles aren't files, but directories, so in fact I need to be
able to compare directories (invisible files included)
* OS 9 files still have resource forks as well as data forks, so both
need to be checked
Another issue is of course performance. Comparing byte-by-byte is
certainly the simplest and most reliable way of doing this, but it's
SLOW.. on the other hand I don't really know what the performance
characteristics of an MD5, CRC32, or SHA hash are and whether or not
you need to read in the whole file contents to apply them..
It would thus be great if somebody, somewhere had published a ready-to-
use - (BOOL) file: (NSString*) path isIdenticalTo: (NSString*) path2;
method :-)
I've spent the last two hours searching the web, but I haven't found
anything that comes close..
Has anybody ever come across such a library?
If not, would you be using a hash function rather than a byte-by-byte
comparison?
All this would be for Mac OS X 10.4 or later.
I'd appreciate your insights, thanks for your time.
Best regards,
Frank
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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