MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / newTempFile

Function newTempFile

modules/dasSQLITE/sqlite/shell.c:21549–21576  ·  view source on GitHub ↗

** Create a new temp file name with the given suffix. */

Source from the content-addressed store, hash-verified

21547** Create a new temp file name with the given suffix.
21548*/
21549static void newTempFile(ShellState *p, const char *zSuffix){
21550 clearTempFile(p);
21551 sqlite3_free(p->zTempFile);
21552 p->zTempFile = 0;
21553 if( p->db ){
21554 sqlite3_file_control(p->db, 0, SQLITE_FCNTL_TEMPFILENAME, &p->zTempFile);
21555 }
21556 if( p->zTempFile==0 ){
21557 /* If p->db is an in-memory database then the TEMPFILENAME file-control
21558 ** will not work and we will need to fallback to guessing */
21559 char *zTemp;
21560 sqlite3_uint64 r;
21561 sqlite3_randomness(sizeof(r), &r);
21562 zTemp = getenv("TEMP");
21563 if( zTemp==0 ) zTemp = getenv("TMP");
21564 if( zTemp==0 ){
21565#ifdef _WIN32
21566 zTemp = "\\tmp";
21567#else
21568 zTemp = "/tmp";
21569#endif
21570 }
21571 p->zTempFile = sqlite3_mprintf("%s/temp%llx.%s", zTemp, r, zSuffix);
21572 }else{
21573 p->zTempFile = sqlite3_mprintf("%z.%s", p->zTempFile, zSuffix);
21574 }
21575 shell_check_oom(p->zTempFile);
21576}
21577
21578
21579/*

Callers 1

do_meta_commandFunction · 0.85

Calls 2

clearTempFileFunction · 0.85
shell_check_oomFunction · 0.85

Tested by

no test coverage detected