* msTmpPath() * * Return the temporary path based on the platform. * * Returns char* which must be freed by caller. **********************************************************************/
| 1375 | * Returns char* which must be freed by caller. |
| 1376 | **********************************************************************/ |
| 1377 | char *msTmpPath(mapObj *map, const char *mappath, const char *tmppath) |
| 1378 | { |
| 1379 | char szPath[MS_MAXPATHLEN]; |
| 1380 | const char *fullPath; |
| 1381 | const char *tmpBase; |
| 1382 | #ifdef _WIN32 |
| 1383 | DWORD dwRetVal = 0; |
| 1384 | TCHAR lpTempPathBuffer[MAX_PATH]; |
| 1385 | #endif |
| 1386 | |
| 1387 | if( ForcedTmpBase != NULL ) |
| 1388 | tmpBase = ForcedTmpBase; |
| 1389 | else if (tmppath != NULL) |
| 1390 | tmpBase = tmppath; |
| 1391 | else if (getenv("MS_TEMPPATH")) |
| 1392 | tmpBase = getenv("MS_TEMPPATH"); |
| 1393 | else if (map && map->web.temppath) |
| 1394 | tmpBase = map->web.temppath; |
| 1395 | else /* default paths */ |
| 1396 | { |
| 1397 | #ifndef _WIN32 |
| 1398 | tmpBase = "/tmp/"; |
| 1399 | #else |
| 1400 | dwRetVal = GetTempPath(MAX_PATH, // length of the buffer |
| 1401 | lpTempPathBuffer); // buffer for path |
| 1402 | if (dwRetVal > MAX_PATH || (dwRetVal == 0)) |
| 1403 | { |
| 1404 | tmpBase = "C:\\"; |
| 1405 | } |
| 1406 | else |
| 1407 | { |
| 1408 | tmpBase = (char*)lpTempPathBuffer; |
| 1409 | } |
| 1410 | #endif |
| 1411 | } |
| 1412 | |
| 1413 | fullPath = msBuildPath(szPath, mappath, tmpBase); |
| 1414 | return strdup(fullPath); |
| 1415 | } |
| 1416 | |
| 1417 | /********************************************************************** |
| 1418 | * msTmpFilename() |
no test coverage detected