Re: Automatic file numbering ideas...
Re: Automatic file numbering ideas...
- Subject: Re: Automatic file numbering ideas...
- From: "Stephen J. Butler" <email@hidden>
- Date: Sun, 23 Nov 2008 13:58:30 -0600
On Sun, Nov 23, 2008 at 12:55 PM, Andrew Merenbach
<email@hidden> wrote:
> I used something pretty much identical in a program of mine, but quickly
> realized that, although it worked, it wasn't scalable enough -- it made me
> feel a little uneasy. For instance, if you are saving a file over a slow
> network, it'll have to check each file's existence every time -- but it
> could take significantly longer for each file in such a case. I'm not sure
> what would be best, frankly. I hope that someone else will chime in with a
> built-in solution!
Well, you could use the same type of strategy that is used in a binary
search. For example:
1) Choose a reasonable window size (say, 10).
2) Check for files existing at multiples of the window (Picture 0,
Picture 10, Picture 20, etc).
3) At the first not found, check the halfway point of the interval
(Between Picture 10 and Picture 20, check Picture 15).
4) Narrow until you find the last file.
But I wouldn't go through all that work w/o first verifying that the
stat() calls on a large directory are a significant portion of the
file saving time.
_______________________________________________
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