update: add full_path to readTemplateFile

This commit is contained in:
Lucas F. 2026-01-14 14:14:59 -03:00
parent 7f47cf440b
commit 8b36704652

View file

@ -41,14 +41,17 @@ pub const Renderer = struct {
return null; return null;
} }
fn readTemplateFile(self: *const Renderer, path: []const u8) RenderError![]const u8 { fn readTemplateFile(self: *const Renderer, path: []const u8) ![]const u8 {
const max_size = 10 * 1024 * 1024; const max_size = 10 * 1024 * 1024;
return std.fs.cwd().readFileAlloc(self.allocator, path, max_size) catch |err| switch (err) {
error.FileNotFound => return RenderError.FileNotFound, const full_path = try std.fs.path.join(self.allocator, &.{ self.cache.default_path.?, path });
error.AccessDenied => return RenderError.AccessDenied, defer self.allocator.free(full_path);
error.FileTooBig => return RenderError.FileTooBig,
error.NoSpaceLeft => return RenderError.NoSpaceLeft, const file = try std.fs.cwd().openFile(full_path, .{});
error.OutOfMemory => return RenderError.OutOfMemory, defer file.close();
// return std.fs.cwd().readFileAlloc(self.allocator, path, max_size) catch |err| switch (err) {
return file.readToEndAlloc(self.allocator, max_size) catch |err| switch (err) {
else => return RenderError.Unexpected, else => return RenderError.Unexpected,
}; };
} }