@@ -844,6 +844,16 @@ pub const Directory = struct {
844
844
if (self .path ) | p | gpa .free (p );
845
845
self .* = undefined ;
846
846
}
847
+
848
+ pub fn tmpFilePath (self : * const Directory , ally : Allocator , suffix : []const u8 ) error {OutOfMemory }! []const u8 {
849
+ const s = std .fs .path .sep_str ;
850
+ const rand_int = std .crypto .random .int (u64 );
851
+ if (self .path ) | p | {
852
+ return std .fmt .allocPrint (ally , "{s}" ++ s ++ "tmp" ++ s ++ "{x}-{s}" , .{ p , rand_int , suffix });
853
+ } else {
854
+ return std .fmt .allocPrint (ally , "tmp" ++ s ++ "{x}-{s}" , .{ rand_int , suffix });
855
+ }
856
+ }
847
857
};
848
858
849
859
pub const EmitLoc = struct {
@@ -4061,7 +4071,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
4061
4071
4062
4072
// We can't know the digest until we do the C compiler invocation,
4063
4073
// so we need a temporary filename.
4064
- const out_obj_path = try comp .tmpFilePath (arena , o_basename );
4074
+ const out_obj_path = try comp .local_cache_directory . tmpFilePath (arena , o_basename );
4065
4075
var zig_cache_tmp_dir = try comp .local_cache_directory .handle .makeOpenPath ("tmp" , .{});
4066
4076
defer zig_cache_tmp_dir .close ();
4067
4077
@@ -4209,16 +4219,6 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
4209
4219
};
4210
4220
}
4211
4221
4212
- pub fn tmpFilePath (comp : * Compilation , ally : Allocator , suffix : []const u8 ) error {OutOfMemory }! []const u8 {
4213
- const s = std .fs .path .sep_str ;
4214
- const rand_int = std .crypto .random .int (u64 );
4215
- if (comp .local_cache_directory .path ) | p | {
4216
- return std .fmt .allocPrint (ally , "{s}" ++ s ++ "tmp" ++ s ++ "{x}-{s}" , .{ p , rand_int , suffix });
4217
- } else {
4218
- return std .fmt .allocPrint (ally , "tmp" ++ s ++ "{x}-{s}" , .{ rand_int , suffix });
4219
- }
4220
- }
4221
-
4222
4222
pub fn addTranslateCCArgs (
4223
4223
comp : * Compilation ,
4224
4224
arena : Allocator ,
0 commit comments