Re: Identify image file count in directory
Re: Identify image file count in directory
- Subject: Re: Identify image file count in directory
- From: "Gary L. Wade" <email@hidden>
- Date: Fri, 13 Nov 2015 08:54:35 -0800
Try going down a level to the BSD layer APIs for directory contents traversal.
--
Gary L. Wade (Sent from my iPad)
http://www.garywade.com/
> On Nov 13, 2015, at 8:28 AM, Jonathan Taylor <email@hidden> wrote:
>
> Hi all,
>
> I want to be able to identify quickly (programatically) how many image files reside in a particular directory. At present I call:
> [NSFileManager defaultManager] contentsOfDirectoryAtPath:dir error:nil];
> and then examine the type suffixes (which in comparison is very quick). When looking at a directory over a network or on an external drive, the NSFileManager call can take several seconds for a directory containing 18k files of which half are images.
>
> These sorts of numbers are in fact a common use case for me, and I would like to avoid this delay. This is for preview information in an NSOpenPanel, so I don't want to make things this unresponsive - but at the same time it is very useful to have access to this information for the preview.
>
> Can anybody advise on a quicker way of achieving what I want to achieve? The fact that 'ls' takes almost as long makes me think this is probably a fairly insurmountable problem, but at the same time the quantity of information transferred (of the order of 200k of data) should not take 2 seconds to transfer, so in that sense it doesn't seem unreasonable to try and see if there is a faster way.
>
> I would prefer to get the filenames themselves, but I could settle for just a count of the total number of files (of any kind) in the directory *and* the ability to get the paths of just the first few files in the directory, if there might be a faster way of doing that.
>
> Thanks for any suggestions
> Jonny
_______________________________________________
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