Skip to content

Commit ef3e263

Browse files
committed
platform independent tmp
1 parent 0ee9c2a commit ef3e263

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

utils/dasFormatter/fmt.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "../src/parser/parser_state.h"
44

55
#include <fstream>
6+
#include <filesystem>
67

78
#include "daScript/ast/ast.h"
89

@@ -169,12 +170,12 @@ Result transform_syntax(const string &filename, const string content, format::Fo
169170

170171
int iter = 0;
171172
policies.version_2_syntax = false;
172-
const auto tmp_name1 = "/tmp/tmp1.das";
173+
const auto tmp_name1 = std::filesystem::temp_directory_path() / "tmp1.das";
173174
{
174175
std::ofstream ostream(tmp_name1);
175176
ostream << src.c_str();
176177
}
177-
auto src_program = parseDaScript(tmp_name1, "", access, tout, libGroup, true, true, policies);
178+
auto src_program = parseDaScript(tmp_name1.string(), "", access, tout, libGroup, true, true, policies);
178179
while (prev != src) {
179180
prev = src;
180181

@@ -236,14 +237,14 @@ Result transform_syntax(const string &filename, const string content, format::Fo
236237
if (!options.contains(FormatOpt::SemicolonEOL)) {
237238
src = remove_semicolons(src, options.contains(FormatOpt::V2Syntax));
238239
}
239-
const auto tmp_name = "/tmp/tmp.das";
240+
const auto tmp_name = std::filesystem::temp_directory_path() / "tmp.das";
240241
{
241242
std::ofstream ostream(tmp_name);
242243
ostream << src.c_str();
243244
ostream.flush();
244245
}
245246
policies.version_2_syntax = options.contains(format::FormatOpt::V2Syntax);
246-
auto program = parseDaScript(tmp_name, "", access, tout, libGroup, true, true, policies);
247+
auto program = parseDaScript(tmp_name.string(), "", access, tout, libGroup, true, true, policies);
247248
Result res;
248249
if (!program->failed()) {
249250
res.ok = src; // designated initializers not supported in CI

0 commit comments

Comments
 (0)