Hi Guys,
I have a need to copy an existing file, or resource, into a temporary file. I can use the QTemporaryFile to create an empty temporary file in a safe fashion. However, to use QFile::copy() to move my data I need the target file to not exist. If I grab the fileName() and remove the temp file then I have put myself back into the race condition that tmpnam (3) warns against and that QTemporaryFile is designed to avoid. There does not seem to be a file copy that uses open QFile (QIODevice) as source and target.
Is there an elegant QT approach to this problem?
Cheers,
Chris
Edit: I can use QTemporaryFile::createLocalFile() on the resource to get the copy on to disc, but this will not copy an already local file.
Bookmarks