MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / CreateTempDir

Function CreateTempDir

fem/code_generation.cpp:20–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 bool code_uses_equivalence_keys = false;
19
20 filesystem::path CreateTempDir()
21 {
22 static int counter = 0;
23 int rank = 0;
24#ifdef PARALLEL
25 if(MPI_Loaded())
26 rank = ngcore::NgMPI_Comm(NG_MPI_COMM_WORLD).Rank();
27#endif // PARALLEL
28 filesystem::path dir;
29#ifdef WIN32
30 dir = filesystem::path(std::tmpnam(nullptr)).concat("_ngsolve_"+ToString(rank)+"_"+ToString(counter++));
31#else // WIN32
32 string tmp_template = filesystem::temp_directory_path().append("ngsolve_tmp_"+ToString(rank)+"_"+ToString(counter++)+"_XXXXXX");
33 if(mkdtemp(&tmp_template[0])==nullptr)
34 throw Exception("could not create temporary directory");
35 dir = tmp_template;
36#endif // WIN32
37 filesystem::create_directories(dir);
38 return dir;
39 }
40
41 atomic<unsigned> Code::id_counter{0};
42

Callers 3

CompileCodeFunction · 0.85

Calls 1

ToStringFunction · 0.85

Tested by

no test coverage detected