write tool fixes
This commit is contained in:
@@ -192,15 +192,27 @@ void mkdir_p(std::string_view dir) {
|
||||
}
|
||||
mkdir(path.c_str(), 0755);
|
||||
}
|
||||
std::string bantam_tmp_dir() {
|
||||
std::string bantam_tmp_dir(std::string_view sess_id) {
|
||||
const char *tmp = std::getenv("TMPDIR");
|
||||
if (!tmp || !*tmp) tmp = "/tmp";
|
||||
std::string p = std::string(tmp) + "/bantam";
|
||||
std::string base(tmp);
|
||||
/* Drop a single trailing slash so we never build a "//bantam" path (which
|
||||
* some platforms treat as a special "super-root"); keep "/" itself intact. */
|
||||
if (base.size() > 1 && base.back() == '/') base.pop_back();
|
||||
std::string p = base;
|
||||
if (p != "/") p += "/";
|
||||
p += "bantam";
|
||||
/* Segregate temporary artifacts per session so different projects/sessions
|
||||
* never share or collide on scratch files. */
|
||||
std::string sid(sess_id);
|
||||
if (sid.empty()) sid = project_id();
|
||||
if (!sid.empty()) { p += "/"; p += sid; }
|
||||
mkdir_p(p);
|
||||
return p;
|
||||
}
|
||||
std::string tool_res_dir() {
|
||||
std::string base = bantam_tmp_dir();
|
||||
|
||||
std::string tool_res_dir(std::string_view sess_id) {
|
||||
std::string base = bantam_tmp_dir(sess_id);
|
||||
std::string p = base + "/toolres";
|
||||
mkdir_p(p);
|
||||
return p;
|
||||
|
||||
Reference in New Issue
Block a user