PIFile::openTemporary on Windows
PIPair from std::tuple
This commit is contained in:
@@ -71,6 +71,10 @@ if (NOT BUILDING_pip)
|
|||||||
find_library(PTHREAD_LIBRARY pthread)
|
find_library(PTHREAD_LIBRARY pthread)
|
||||||
find_library(UTIL_LIBRARY util)
|
find_library(UTIL_LIBRARY util)
|
||||||
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
|
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
|
||||||
|
if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT PIP_FREERTOS))
|
||||||
|
find_library(RT_LIBRARY rt)
|
||||||
|
list(APPEND _PIP_ADD_LIBS_ ${RT_LIBRARY})
|
||||||
|
endif()
|
||||||
list(APPEND PIP_LIBRARY ${_PIP_ADD_LIBS_})
|
list(APPEND PIP_LIBRARY ${_PIP_ADD_LIBS_})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ template<typename Type0, typename Type1>
|
|||||||
class PIPair {
|
class PIPair {
|
||||||
public:
|
public:
|
||||||
PIPair() {first = Type0(); second = Type1();}
|
PIPair() {first = Type0(); second = Type1();}
|
||||||
|
PIPair(std::tuple<Type0, Type1> tuple) {first = std::get<0>(tuple); second = std::get<1>(tuple);}
|
||||||
PIPair(const Type0 & value0, const Type1 & value1) {first = value0; second = value1;}
|
PIPair(const Type0 & value0, const Type1 & value1) {first = value0; second = value1;}
|
||||||
Type0 first;
|
Type0 first;
|
||||||
Type1 second;
|
Type1 second;
|
||||||
|
|||||||
@@ -149,12 +149,15 @@ PIFile::PIFile(const PIString & path, PIIODevice::DeviceMode mode): PIIODevice(p
|
|||||||
|
|
||||||
bool PIFile::openTemporary(PIIODevice::DeviceMode mode) {
|
bool PIFile::openTemporary(PIIODevice::DeviceMode mode) {
|
||||||
PIString tp;
|
PIString tp;
|
||||||
|
#ifdef WINDOWS
|
||||||
|
tp = PIDir::temporary().path() + PIDir::separator + "file" + PIString::fromNumber(randomi());
|
||||||
|
#else
|
||||||
char * rc = tmpnam(0);
|
char * rc = tmpnam(0);
|
||||||
if (!rc) return false;
|
if (!rc) return false;
|
||||||
tp = rc;
|
tp = rc;
|
||||||
#ifdef WINDOWS
|
|
||||||
tp = PIDir::temporary().path() + PIDir::separator + "file" + tp.cutLeft(1).cutRight(1);
|
|
||||||
#endif
|
#endif
|
||||||
|
while (isExists(tp))
|
||||||
|
tp += PIString::fromNumber(randomi() % 10);
|
||||||
return open(tp, mode);
|
return open(tp, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user