add os.tmpDir to get the recommended temp dir base path

This commit is contained in:
Mitchell Hashimoto
2023-07-09 11:58:04 -07:00
parent 791e1a84af
commit 26e17de777

View File

@ -50,3 +50,10 @@ pub fn fixMaxFiles() void {
log.debug("file handle limit raised value={}", .{lim.cur});
}
/// Return the recommended path for temporary files.
pub fn tmpDir() ?[]const u8 {
if (std.os.getenv("TMPDIR")) |v| return v;
if (std.os.getenv("TMP")) |v| return v;
return "/tmp";
}