PIFile::openTemporary on Windows
PIPair from std::tuple
This commit is contained in:
@@ -149,12 +149,15 @@ PIFile::PIFile(const PIString & path, PIIODevice::DeviceMode mode): PIIODevice(p
|
||||
|
||||
bool PIFile::openTemporary(PIIODevice::DeviceMode mode) {
|
||||
PIString tp;
|
||||
#ifdef WINDOWS
|
||||
tp = PIDir::temporary().path() + PIDir::separator + "file" + PIString::fromNumber(randomi());
|
||||
#else
|
||||
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
|
||||
while (isExists(tp))
|
||||
tp += PIString::fromNumber(randomi() % 10);
|
||||
return open(tp, mode);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user