| 54 | // --------------------------------------------------------------------------- |
| 55 | |
| 56 | static std::string createTempDict(std::string &dirname, const char *filename) { |
| 57 | const char *temp_dir = getenv("TEMP"); |
| 58 | if (!temp_dir) { |
| 59 | temp_dir = getenv("TMP"); |
| 60 | } |
| 61 | #ifndef WIN32 |
| 62 | if (!temp_dir) { |
| 63 | temp_dir = "/tmp"; |
| 64 | } |
| 65 | #endif |
| 66 | if (!temp_dir) |
| 67 | return std::string(); |
| 68 | |
| 69 | dirname = temp_dir; |
| 70 | |
| 71 | std::string tmpFilename; |
| 72 | tmpFilename = temp_dir; |
| 73 | tmpFilename += DIR_CHAR; |
| 74 | tmpFilename += filename; |
| 75 | |
| 76 | return createTmpFile(tmpFilename) ? tmpFilename : std::string(); |
| 77 | } |
| 78 | |
| 79 | // --------------------------------------------------------------------------- |
| 80 | |