fix warning tmpnam
This commit is contained in:
@@ -176,14 +176,16 @@ 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;
|
||||
#endif
|
||||
while (isExists(tp)) {
|
||||
tp += PIString::fromNumber(randomi() % 10);
|
||||
}
|
||||
#else
|
||||
char template_rc[] = "/tmp/pifile_tmp_XXXXXX";
|
||||
int fd = mkstemp(template_rc);
|
||||
if (fd == -1) return false;
|
||||
::close(fd);
|
||||
tp = template_rc;
|
||||
#endif
|
||||
return open(tp, mode);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user