SQLite Forum

Can I get the file name of a temporary on-disk database?
Login
Thanks for that info Richard. I am curious, though, why tmpnam has not been made more robust as the improvements you mentioned came along, so that the file name it produces benefits from the increased randomness. Would there have been any issues with backwards compatibility of code that somehow came to rely on its old and insufficient behaviour? Hard to imagine why that would be the case.

Instead (or rather, in addition to that increased randomness), the recommended solution is a function like mkstemp, which guarantees no "holes" between file *name* creation and creation of a file with that name. There doesn't seem to be a way to just get the file name like tmpnam did, but which has the improved randomness in it to make the race condition a non-issue.

I'm no expert on this topic so perhaps there's a good explanation that's not evident to me.

Tim