Begin design of comment evaluation and {{variables}}
This commit is contained in:
@@ -1172,3 +1172,25 @@ API void CloseStdin(Process *process) {
|
||||
API double GetTimeSeconds() {
|
||||
return GetTimeMicros() / 1000000.0;
|
||||
}
|
||||
|
||||
API String WriteTempFile(String data) {
|
||||
Scratch scratch;
|
||||
|
||||
#if OS_WINDOWS
|
||||
int buffer_len = MAX_PATH+1;
|
||||
char16_t *buffer = AllocArray(scratch, char16_t, buffer_len);
|
||||
Assert(sizeof(char16_t) == sizeof(wchar_t));
|
||||
DWORD result = GetTempPath2W(buffer_len, (LPWSTR)buffer);
|
||||
Assert(result != 0);
|
||||
String16 temp16 = {buffer, result};
|
||||
NormalizePathInPlace(temp16);
|
||||
String temp_directory = ToString(scratch, temp16);
|
||||
#else
|
||||
String temp_directory = "/tmp";
|
||||
#endif
|
||||
|
||||
String temp_filename = Format(scratch, "%S/temp%llu", temp_directory, GetTimeNanos());
|
||||
bool done = WriteFile(temp_filename, data);
|
||||
Assert(done);
|
||||
return temp_filename;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user