6 Aug
2006
6 Aug
'06
12:39
I just want to add that using date and time today on fast multi-tasking
systems will not give you the uniqueness you need. The mkstemp(3)
function will give you a guaranteed unique name.
Note that in my quick and dirty example, I did not add the
file extension. If you do need to add the extension, do it after the
mkstemp() call since the XXXXXX template must be the last 6 characters.
You can easily do this:
char *ext;
ext = strrchr(OldName, '.');
: /* after mkstemp but before rename */
if (ext != NULL)
strcat(NewNanme, ext);
--
Jerry Feldman