Hi everyone,

I'm recreating a Finder-like column view fro browsing the disk, and I've come up against some optimization impasses.

First off, I'm using passive-loading, so that I only load information regarding an item once I get the browser:willDisplayCell: message. This works wonderfully for lazy loading.

My problem lies before that. I'm trying to mimic the Finder, so I want to not show hidden files if they're not visible in Finder. When I obtain a directory listing via NSFileManager, it includes everything (including hidden files). Once I get that listing, I filter it based with an "isFileVisible = YES" predicate, which calls an -[NSString isFileVisible] method I've implemented in a category. This method checks the three standard ways of hiding a file to determine its visibility (prefixed with ".", a flipped invisible bit, or listing it in /.hidden [which is deprecated, but I need to support older systems]).

Once I've filtered the array, I sort it using a custom "compareLikeFinder:" method, which sorts items into the same order as they appear in Finder.

For normal-sized directories, this works pretty well. However, in my "worst-case" scenario of a flat directory containing 1 million files, I've found that it takes 34.8 seconds to retrieve a full directory listing (so I know how many to return in browser:numberOfRowsInColumn:), 301.5 seconds to filter the array, and another 73.6 seconds to sort it.

Believe it or not, this is actually better than the current implementation, but I'd like to do even better. On that note, here are my questions:

1. How can I obtain a count of files in a directory without retrieving the actual listing of contents? (I can scan through the folder and count by just grabbing catalog infos myself, but is there a faster way?) 2. How can I retrieve the name of the nth item in a directory without retrieving the actual listing of contents?

Thanks!

Dave DeLong
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to