in reply to Re^2: Generate a unique ID
in thread Generate a unique ID
If you use a random identifier that is long enough, I do believe that it becomes irrelevant to seriously consider “collisions.” You will have won the Lottery in every state and every country, and retired to a place where you do not have to give a tinker’s dam about computers, long before a collision actually occurs.
The sequence that you expect to succeed will be: to create the directory, write some sentinel file into it, and verify that the sentinel file does exist. If you can do all that, you’re good to go.
If you cannot create the directory, then I submit that it is safe to assume that the reason is “permissions.” Even though meteors can fall from the sky and lodge themselves in your microwave oven just to the left of your turkey sandwich, you don’t need to test for them.