MCPcopy Create free account
hub / github.com/audacity/audacity / newTempFile

Function newTempFile

lib-src/sqlite/shell.c:15793–15823  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

15791** Create a new temp file name with the given suffix.
15792*/
15793static void newTempFile(ShellState *p, const char *zSuffix){
15794 clearTempFile(p);
15795 sqlite3_free(p->zTempFile);
15796 p->zTempFile = 0;
15797 if( p->db ){
15798 sqlite3_file_control(p->db, 0, SQLITE_FCNTL_TEMPFILENAME, &p->zTempFile);
15799 }
15800 if( p->zTempFile==0 ){
15801 /* If p->db is an in-memory database then the TEMPFILENAME file-control
15802 ** will not work and we will need to fallback to guessing */
15803 char *zTemp;
15804 sqlite3_uint64 r;
15805 sqlite3_randomness(sizeof(r), &r);
15806 zTemp = getenv("TEMP");
15807 if( zTemp==0 ) zTemp = getenv("TMP");
15808 if( zTemp==0 ){
15809#ifdef _WIN32
15810 zTemp = "\\tmp";
15811#else
15812 zTemp = "/tmp";
15813#endif
15814 }
15815 p->zTempFile = sqlite3_mprintf("%s/temp%llx.%s", zTemp, r, zSuffix);
15816 }else{
15817 p->zTempFile = sqlite3_mprintf("%z.%s", p->zTempFile, zSuffix);
15818 }
15819 if( p->zTempFile==0 ){
15820 raw_printf(stderr, "out of memory\n");
15821 exit(1);
15822 }
15823}
15824
15825
15826/*

Callers 1

do_meta_commandFunction · 0.85

Calls 1

clearTempFileFunction · 0.85

Tested by

no test coverage detected