work with PIFile::openTemporary() on Windows

This commit is contained in:
2021-10-26 13:50:27 +03:00
parent f781cc3846
commit b85de0d704

View File

@@ -148,7 +148,14 @@ PIFile::PIFile(const PIString & path, PIIODevice::DeviceMode mode): PIIODevice(p
bool PIFile::openTemporary(PIIODevice::DeviceMode mode) {
return open(PIString(tmpnam(0)), mode);
PIString tp;
char * rc = tmpnam(0);
if (!rc) return false;
tp = rc;
#ifdef WINDOWS
tp = PIDir::temporary().path() + PIDir::separator + "file" + tp.cutLeft(1).cutRight(1);
#endif
return open(tp, mode);
}