MCPcopy Create free account
hub / github.com/crownengine/crown / getTempPath

Function getTempPath

3rdparty/bx/src/filepath.cpp:240–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238 }
239
240 static bool getTempPath(char* _out, uint32_t* _inOutSize)
241 {
242#if BX_PLATFORM_WINDOWS
243 uint32_t len = ::GetTempPathA(*_inOutSize, _out);
244 bool result = len != 0 && len < *_inOutSize;
245 *_inOutSize = len;
246 return result;
247#else
248 static const StringView s_tmp[] =
249 {
250 "TMPDIR",
251 "TMP",
252 "TEMP",
253 "TEMPDIR",
254
255 ""
256 };
257
258 for (const StringView* tmp = s_tmp; !tmp->isEmpty(); ++tmp)
259 {
260 uint32_t len = *_inOutSize;
261 *_out = '\0';
262 bool ok = getEnv(_out, &len, *tmp, FileType::Dir);
263
264 if (ok
265 && len != 0
266 && len < *_inOutSize)
267 {
268 *_inOutSize = len;
269 return ok;
270 }
271 }
272
273 FileInfo fi;
274 if (stat(fi, "/tmp")
275 && FileType::Dir == fi.type)
276 {
277 strCopy(_out, *_inOutSize, "/tmp");
278 *_inOutSize = 4;
279 return true;
280 }
281
282 return false;
283#endif // BX_PLATFORM_*
284 }
285
286 FilePath::FilePath()
287 {

Callers 1

setMethod · 0.85

Calls 4

strCopyFunction · 0.85
getEnvFunction · 0.70
statFunction · 0.70
isEmptyMethod · 0.45

Tested by

no test coverage detected