Skip to content

Commit

Permalink
add os.tmpDir to get the recommended temp dir base path
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jul 9, 2023
1 parent 791e1a8 commit 26e17de
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/os/file.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

0 comments on commit 26e17de

Please sign in to comment.