//============================================================================
std::string GetTmpDir()
{
-
//Find a temporary directory to store a file
-
std::string aTmpDir;
-
char *Tmp_dir = getenv("SALOME_TMP_DIR");
if(Tmp_dir != NULL) {
aTmpDir = std::string(Tmp_dir);
if(aTmpDir[aTmpDir.size()-1] != dir_separator) aTmpDir+=dir_separator;
-/*#ifdef WIN32
- if(aTmpDir[aTmpDir.size()-1] != '\\') aTmpDir+='\\';
-#else
- if(aTmpDir[aTmpDir.size()-1] != '/') aTmpDir+='/';
-#endif*/
}
else {
#ifdef WIN32
aTmpDir += aSubDir; //Get RND sub directory
if(aTmpDir[aTmpDir.size()-1] != dir_separator) aTmpDir+=dir_separator;
-/*
-#ifdef WIN32
- if(aTmpDir[aTmpDir.size()-1] != '\\') aTmpDir+='\\';
-#else
- if(aTmpDir[aTmpDir.size()-1] != '/') aTmpDir+='/';
-#endif
- */
std::string aDir = aTmpDir;
aRND = 0;
while( Exists(aDir) ) {
sprintf(buffer, "%d", aRND);
aDir = aTmpDir+buffer; //Build a unique directory name
- aRND++;
+ aRND++;
}
#ifdef WIN32
bool Exists(const std::string thePath)
{
#ifdef WIN32
- if ( GetFileAttributes ( thePath.c_str() ) == 0xFFFFFFFF ) {
- if ( GetLastError () != ERROR_FILE_NOT_FOUND ) {
- return false;
- }
- }
+ return (GetFileAttributes( thePath.c_str() ) != 0xFFFFFFFF);
#else
int status = access ( thePath.c_str() , F_OK );
if (status != 0) return false;