/** @brief Returns the file component of a path (reimplementation of POSIX basename) */
std::string get_base_name() const;
+ /** @brief Returns the name of a directory suitable for creating temporary files (e.g. "/tmp") */
+ static Path get_tmpdir();
+
private:
std::string path_;
};
std::string p(path_);
return basename(&p[0]);
}
+
+simgrid::xbt::Path simgrid::xbt::Path::get_tmpdir()
+{
+ for (const char* name : {"TMPDIR", "TMP", "TEMP", "TEMPDIR"}) {
+ char* val = getenv(name);
+ if (val != nullptr)
+ return Path(val);
+ }
+ return Path("/tmp");
+}