Writing to unique files
| From: | Louis Aslett | Date: | Mon, 04 Dec 2000 21:24:22 +0000 |
| Subject: | Writing to unique files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-28641@lists.php.net to get a copy of this message | ||
Hi,
Does anybody have any neat tricks for a good way to choose unique sequential
filenames in the following format?:
abc-000001.xyz
abc-000002.xyz
etc ....
in other words, what fast methods are there for creating a new file which
will be the next in the sequence in a directory where the files follow the
above format? Is there any quicker way than laboriously reading in every
directory entry, extracting the number and then determining the largest
value and adding one!? Also, how can one guard against potential conflicts
(ie two processes running at such a close time that they both select the
same filename)?
Many thanks in advance!
Louis