| 59 | } |
| 60 | |
| 61 | void temp_fstream::open (std::ios_base::openmode mode) |
| 62 | { |
| 63 | close(); |
| 64 | |
| 65 | char tmpdir[MAX_PATH + 1]; |
| 66 | |
| 67 | DWORD ret = GetTempPath(sizeof(tmpdir), tmpdir); |
| 68 | if (ret == 0) { |
| 69 | throw System_error("GetTempPath", "", GetLastError()); |
| 70 | } else if (ret > sizeof(tmpdir) - 1) { |
| 71 | throw System_error("GetTempPath", "", ERROR_BUFFER_OVERFLOW); |
| 72 | } |
| 73 | |
| 74 | char tmpfilename[MAX_PATH + 1]; |
| 75 | if (GetTempFileName(tmpdir, TEXT("git-crypt"), 0, tmpfilename) == 0) { |
| 76 | throw System_error("GetTempFileName", "", GetLastError()); |
| 77 | } |
| 78 | |
| 79 | filename = tmpfilename; |
| 80 | |
| 81 | std::fstream::open(filename.c_str(), mode); |
| 82 | if (!std::fstream::is_open()) { |
| 83 | DeleteFile(filename.c_str()); |
| 84 | throw System_error("std::fstream::open", filename, 0); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | void temp_fstream::close () |
| 89 | { |
nothing calls this directly
no test coverage detected