> On Apr 16, 2016, at 3:20 PM, Quincey Morris > <[email protected]> wrote: > > On Apr 16, 2016, at 15:10 , Carl Hoefs <[email protected] > <mailto:[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. >
For a single sequence, it wouldn't be so bad, but I have potentially n different ongoing sequences, so it seems like this approach could end up hitting the filesystem really hard. I'll code it up and see how inefficient it becomes. -Carl _______________________________________________ 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]
