Function format [src]

Prototype

pub fn format( self: Path, comptime fmt_string: []const u8, options: std.fmt.FormatOptions, writer: anytype, ) !void

Parameters

self: Pathfmt_string: []const u8options: std.fmt.FormatOptions

Source

pub fn format( self: Path, comptime fmt_string: []const u8, options: std.fmt.FormatOptions, writer: anytype, ) !void { if (fmt_string.len == 1) { // Quote-escape the string. const stringEscape = std.zig.stringEscape; const f = switch (fmt_string[0]) { 'q' => "", '\'' => "\'", else => @compileError("unsupported format string: " ++ fmt_string), }; if (self.root_dir.path) |p| { try stringEscape(p, f, options, writer); if (self.sub_path.len > 0) try stringEscape(fs.path.sep_str, f, options, writer); } if (self.sub_path.len > 0) { try stringEscape(self.sub_path, f, options, writer); } return; } if (fmt_string.len > 0) std.fmt.invalidFmtError(fmt_string, self); if (std.fs.path.isAbsolute(self.sub_path)) { try writer.writeAll(self.sub_path); return; } if (self.root_dir.path) |p| { try writer.writeAll(p); if (self.sub_path.len > 0) { try writer.writeAll(fs.path.sep_str); try writer.writeAll(self.sub_path); } return; } if (self.sub_path.len > 0) { try writer.writeAll(self.sub_path); return; } try writer.writeByte('.'); }