Function nextFilename [src]

Prototype

pub fn nextFilename(self: *Diagnostics, name: []const u8) error{OutOfMemory}!void

Parameters

self: *Diagnosticsname: []const u8

Possible Errors

OutOfMemory

Source

pub fn nextFilename(self: *Diagnostics, name: []const u8) error{OutOfMemory}!void { if (!self.saw_first_file) { self.saw_first_file = true; std.debug.assert(self.root_dir.len == 0); const root_len = std.mem.indexOfScalar(u8, name, '/') orelse return; std.debug.assert(root_len > 0); self.root_dir = try self.allocator.dupe(u8, name[0..root_len]); } else if (self.root_dir.len > 0) { if (!filenameInRoot(name, self.root_dir)) { self.allocator.free(self.root_dir); self.root_dir = ""; } } }