FictionTools/z88dk/src/zcc/zcc.c
/** \brief Get a temporary filename
*/
\brief Get a temporary filename
\ brief Get a temporary filename
void tempname(char *filen)
{
#ifdef _WIN32
    char   *ptr;
    if ((ptr = _tempnam(".\\", tmpnambuf)) == NULL) {
        fprintf(stderr, "Failed to create temporary filename\n");
        exit(1);
    }
    strcpy(filen, ptr);
    free(ptr);
#elif defined(__MSDOS__) && defined(__TURBOC__)
    if (ptr = getenv("TEMP")) {    
        strcpy(filen, ptr);    
        strcat(filen, "\\");
        tmpnam(filen + strlen(filen));    
    }
    else            
        tmpnam(filen);    
    if (ptr = find_file_ext(filen))    
        *ptr = 0;    
#else
    strcpy(filen, "/tmp/tmpXXXXXXXX");
    mktempfile(filen);
#endif
}
void tempname ( char * filen ) { #ifdef _WIN32 char * ptr ; if ( ( ptr = _tempnam ( " \\ " , tmpnambuf ) ) == NULL ) { fprintf ( stderr , " \n " ) ; exit ( 1 ) ; } strcpy ( filen , ptr ) ; free ( ptr ) ; #elif defined ( __MSDOS__ ) && defined ( __TURBOC__ ) if ( ptr = getenv ( " " ) ) { strcpy ( filen , ptr ) ; strcat ( filen , " \\ " ) ; tmpnam ( filen + strlen ( filen ) ) ; } else tmpnam ( filen ) ; if ( ptr = find_file_ext ( filen ) ) * ptr = 0 ; #else strcpy ( filen , " " ) ; mktempfile ( filen ) ; #endif }
\brief Get a temporary filename
\ brief Get a temporary filename
/* Both predefined by Borland's Turbo C/C++ and Borland C/C++ */ /* From MS-DOS 5, C:\TEMP, C:\DOS,
                                    * C:\WINDOWS\TEMP or whatever or
                                    * nothing */ /* Directory is not guaranteed to
                                * exist */ /* Adds strings like
                                           * TMP1.$$$, TMP2.$$$ */ /* Allways starts at TMP1.$$$. Does not */ /* check if file already exists. So is  */ /* not suitable for executing zcc more  */ /* than once without cleaning out
                                        * files. */ /* Don't want to risk too long filenames */