MCPcopy Create free account
hub / github.com/AGWA/git-crypt / open

Method open

util-win32.cpp:61–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void 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
88void temp_fstream::close ()
89{

Callers

nothing calls this directly

Calls 1

System_errorClass · 0.85

Tested by

no test coverage detected