Aggiunta funzione tempnam per WATCOM C++
git-svn-id: svn://10.65.10.50/trunk@1134 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									b7c2e821d1
								
							
						
					
					
						commit
						11f28d4df5
					
				@ -267,3 +267,33 @@ int stricmp(const char* s1, const char* s2)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef __WATCOMC__
 | 
			
		||||
char * tempnam(const char * dir , const char * prefix)
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  TFilename tmpdir(getenv("TMP"));
 | 
			
		||||
  static word counter = 1;
 | 
			
		||||
 | 
			
		||||
  if (tmpdir.empty() || !fexist(tmpdir))
 | 
			
		||||
  {
 | 
			
		||||
    tmpdir = dir;
 | 
			
		||||
    if (tmpdir.empty() || !fexist(tmpdir))
 | 
			
		||||
      tmpdir = "";
 | 
			
		||||
  }
 | 
			
		||||
  if (is_not_slash(tmpdir.right(1)[0]))
 | 
			
		||||
    tmpdir << '/';
 | 
			
		||||
  tmpdir << prefix ;
 | 
			
		||||
  const int lastpos = tmpdir.len() ;
 | 
			
		||||
  tmpdir << format("%ud", counter);
 | 
			
		||||
 | 
			
		||||
  while (!fexist(tmpdir))
 | 
			
		||||
  {
 | 
			
		||||
    counter++;
 | 
			
		||||
    if (counter == 0) counter = 1;
 | 
			
		||||
    tmpdir.cut(lastpos);
 | 
			
		||||
    tmpdir << format("%ud", counter);
 | 
			
		||||
  }
 | 
			
		||||
  return strdup(tmpdir);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -14,10 +14,14 @@ bool fcopy(const char* orig, const char* dest, bool append=FALSE);
 | 
			
		||||
bool fexist(const char* file);
 | 
			
		||||
const char * encode(const char * data);
 | 
			
		||||
const char * decode(const char * data);
 | 
			
		||||
inline bool is_not_slash(char s) {  return s != '\\' && s != '/'; }
 | 
			
		||||
 | 
			
		||||
#if XVT_OS == XVT_OS_SCOUNIX
 | 
			
		||||
int  stricmp(const char*, const char*);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef __WATCOMC__
 | 
			
		||||
char * tempnam(const char * dir, const char * prefix);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
const char* esc(const char*);
 | 
			
		||||
 | 
			
		||||
@ -32,5 +36,5 @@ extern char __tmp_string[1024];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* @END */
 | 
			
		||||
#endif // __UTILITY_H
 | 
			
		||||
#endif /* __UTILITY_H */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user