On Apr 16, 2016, at 14:36 , Carl Hoefs <newsli...@autonomy.caltech.edu> wrote: > > I have a daemon process that needs to generate a series of sequenced files
Oh, sorry, I think I misunderstood the question. I thought you wanted to generate all the files at once. Alex’s interpretation sounds more plausible. If you’re looking to *resume* creating files at the end of an existing sequence, I would just do the simplest thing: 1. When your process starts, initialize a “nextInSequence” number to 0 or 1. 2. When you need to create a new file, construct its name using the “nextInSequence” variable, and increment it. 3. Try creating a new file with that name. If it fails due to conflict with an existing file, repeat step 2. Anything “cleverer” that tries to find the last-used sequence is subject to race conditions, and multiple iterations of step 2 (to get past the files you previously created) aren’t going to take long. Still, I’d suggest you set a hard limit (e.g. 1000 attempts) on iterations, and if you hit the limit, tell the user to remove or otherwise deal with old files. The idea is that if old files are building up without limit, something needs to be done with them anyway, so you may as well be proactive about it. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com