Re: Creating a series of sequenced files
Re: Creating a series of sequenced files
- Subject: Re: Creating a series of sequenced files
- From: Quincey Morris <email@hidden>
- Date: Sat, 16 Apr 2016 15:20:48 -0700
- Feedback-id: 167118m:167118agrif8a:167118sQeEngraHv:SMTPCORP
On Apr 16, 2016, at 15:10 , Carl Hoefs <email@hidden> 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@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