mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 11:17:05 -04:00
Handle realpathAlloc failure in files.zig
This commit is contained in:
parent
62d4bf6700
commit
de3b862f1e
@ -123,9 +123,9 @@ pub const Dir = struct {
|
||||
pub fn readToZon(self: Dir, allocator: NeverFailingAllocator, path: []const u8) !ZonElement {
|
||||
const string = try self.read(main.stackAllocator, path);
|
||||
defer main.stackAllocator.free(string);
|
||||
const realPath = try self.dir.realpathAlloc(main.stackAllocator.allocator, path);
|
||||
defer main.stackAllocator.free(realPath);
|
||||
return ZonElement.parseFromString(allocator, realPath, string);
|
||||
const realPath: ?[]const u8 = self.dir.realpathAlloc(main.stackAllocator.allocator, path) catch null;
|
||||
defer if(realPath) |p| main.stackAllocator.free(p);
|
||||
return ZonElement.parseFromString(allocator, realPath orelse path, string);
|
||||
}
|
||||
|
||||
pub fn write(self: Dir, path: []const u8, data: []const u8) !void {
|
||||
|
Loading…
x
Reference in New Issue
Block a user