On Apr 16, 2016, at 15:10 , Carl Hoefs <[email protected]> wrote:
> 
> But I'm concerned mainly with efficiency, as determining the next number in 
> the naming sequence potentially can be extremely inefficient - trying 1000s 
> of times until the next available number every time a new file needs to be 
> written, and also every time the latest-written file needs to be retrieved. 

If you really need to examine the existing files, then I suggest you start your 
process with a one-time directory enumeration, and find the file that you 
regard as "last". However I foresee that there are actually two things you 
might want to find:

1. The next sequence number to use.

2. The most recently-written file.

There’s really nothing you can do to guarantee that these are the same, in all 
scenarios, so you may as well treat them as separate results.

This would only get complicated if there’s another process creating files in 
your sequence. Otherwise an initial directory enumeration will get you sync-ed 
up, and after that you can just do the simple nextInSequence-incrementing thing.

_______________________________________________

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

This email sent to [email protected]

Reply via email to