Former-commit-id: 7dc3ee4c89
This commit is contained in:
Jarred Sumner
2021-05-30 18:26:18 -07:00
parent 741d35f0b3
commit dd72bf5ab6
9 changed files with 54 additions and 3 deletions

View File

@@ -329,7 +329,18 @@ pub const Cli = struct {
} else |err| {}
did_write = true;
var root_dir = try std.fs.openDirAbsolute(result.outbase, std.fs.Dir.OpenDirOptions{});
var root_dir = std.fs.openDirAbsolute(result.outbase, std.fs.Dir.OpenDirOptions{}) catch brk: {
std.fs.makeDirAbsolute(result.outbase) catch |err| {
Output.printErrorln("error: Unable to mkdir \"{s}\": \"{s}\"", .{ result.outbase, @errorName(err) });
std.os.exit(1);
};
var handle = std.fs.openDirAbsolute(result.outbase, std.fs.Dir.OpenDirOptions{}) catch |err2| {
Output.printErrorln("error: Unable to open \"{s}\": \"{s}\"", .{ result.outbase, @errorName(err2) });
std.os.exit(1);
};
break :brk handle;
};
// On posix, file handles automatically close on process exit by the OS
// Closing files shows up in profiling.
// So don't do that unless we actually need to.
@@ -360,8 +371,13 @@ pub const Cli = struct {
.truncate = true,
}) catch |err2| return err2);
};
try _handle.seekTo(0);
if (FeatureFlags.disable_filesystem_cache) {
_ = std.os.fcntl(_handle.handle, std.os.F_NOCACHE, 1) catch 0;
}
defer {
if (do_we_need_to_close) {
_handle.close();