mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-08 03:29:48 -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 {
|
pub fn readToZon(self: Dir, allocator: NeverFailingAllocator, path: []const u8) !ZonElement {
|
||||||
const string = try self.read(main.stackAllocator, path);
|
const string = try self.read(main.stackAllocator, path);
|
||||||
defer main.stackAllocator.free(string);
|
defer main.stackAllocator.free(string);
|
||||||
const realPath = try self.dir.realpathAlloc(main.stackAllocator.allocator, path);
|
const realPath: ?[]const u8 = self.dir.realpathAlloc(main.stackAllocator.allocator, path) catch null;
|
||||||
defer main.stackAllocator.free(realPath);
|
defer if(realPath) |p| main.stackAllocator.free(p);
|
||||||
return ZonElement.parseFromString(allocator, realPath, string);
|
return ZonElement.parseFromString(allocator, realPath orelse path, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write(self: Dir, path: []const u8, data: []const u8) !void {
|
pub fn write(self: Dir, path: []const u8, data: []const u8) !void {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user