| ... | @@ -415,12 +415,18 @@ pub const Tree = struct { | ... | @@ -415,12 +415,18 @@ pub const Tree = struct { |
| 415 | pub fn format(self: Mode, comptime fmt: string, options: std.fmt.FormatOptions, writer: anytype) !void { | 415 | pub fn format(self: Mode, comptime fmt: string, options: std.fmt.FormatOptions, writer: anytype) !void { |
| 416 | _ = fmt; | 416 | _ = fmt; |
| 417 | _ = options; | 417 | _ = options; |
| 418 | | | |
| 419 | try writer.print("{}", .{self.type}); | 418 | try writer.print("{}", .{self.type}); |
| 420 | try writer.print("{}", .{self.perm_user}); | 419 | try writer.print("{}", .{self.perm_user}); |
| 421 | try writer.print("{}", .{self.perm_group}); | 420 | try writer.print("{}", .{self.perm_group}); |
| 422 | try writer.print("{}", .{self.perm_other}); | 421 | try writer.print("{}", .{self.perm_other}); |
| 423 | } | 422 | } |
| | 423 | |
| | 424 | pub fn nprint(self: Mode, writer: anytype) !void { |
| | 425 | try self.type.nprint(writer); |
| | 426 | try self.perm_user.nprint(writer); |
| | 427 | try self.perm_group.nprint(writer); |
| | 428 | try self.perm_other.nprint(writer); |
| | 429 | } |
| 424 | }; | 430 | }; |
| 425 | | 431 | |
| 426 | pub const Type = enum(u16) { | 432 | pub const Type = enum(u16) { |
| ... | @@ -433,7 +439,6 @@ pub const Tree = struct { | ... | @@ -433,7 +439,6 @@ pub const Tree = struct { |
| 433 | pub fn format(self: Type, comptime fmt: string, options: std.fmt.FormatOptions, writer: anytype) !void { | 439 | pub fn format(self: Type, comptime fmt: string, options: std.fmt.FormatOptions, writer: anytype) !void { |
| 434 | _ = fmt; | 440 | _ = fmt; |
| 435 | _ = options; | 441 | _ = options; |
| 436 | | | |
| 437 | try writer.writeByte(switch (self) { | 442 | try writer.writeByte(switch (self) { |
| 438 | .file => '-', | 443 | .file => '-', |
| 439 | .directory => 'd', | 444 | .directory => 'd', |
| ... | @@ -442,6 +447,16 @@ pub const Tree = struct { | ... | @@ -442,6 +447,16 @@ pub const Tree = struct { |
| 442 | .none => '-', | 447 | .none => '-', |
| 443 | }); | 448 | }); |
| 444 | } | 449 | } |
| | 450 | |
| | 451 | pub fn nprint(self: Type, writer: anytype) !void { |
| | 452 | try writer.writeAll(&.{switch (self) { |
| | 453 | .file => '-', |
| | 454 | .directory => 'd', |
| | 455 | .submodule => 'm', |
| | 456 | .symlink => '-', |
| | 457 | .none => '-', |
| | 458 | }}); |
| | 459 | } |
| 445 | }; | 460 | }; |
| 446 | | 461 | |
| 447 | pub const Perm = packed struct(u3) { | 462 | pub const Perm = packed struct(u3) { |
| ... | @@ -452,11 +467,18 @@ pub const Tree = struct { | ... | @@ -452,11 +467,18 @@ pub const Tree = struct { |
| 452 | pub fn format(self: Perm, comptime fmt: string, options: std.fmt.FormatOptions, writer: anytype) !void { | 467 | pub fn format(self: Perm, comptime fmt: string, options: std.fmt.FormatOptions, writer: anytype) !void { |
| 453 | _ = fmt; | 468 | _ = fmt; |
| 454 | _ = options; | 469 | _ = options; |
| 455 | | | |
| 456 | try writer.writeByte(if (self.read) 'r' else '-'); | 470 | try writer.writeByte(if (self.read) 'r' else '-'); |
| 457 | try writer.writeByte(if (self.write) 'w' else '-'); | 471 | try writer.writeByte(if (self.write) 'w' else '-'); |
| 458 | try writer.writeByte(if (self.execute) 'x' else '-'); | 472 | try writer.writeByte(if (self.execute) 'x' else '-'); |
| 459 | } | 473 | } |
| | 474 | |
| | 475 | pub fn nprint(self: Perm, writer: anytype) !void { |
| | 476 | try writer.writeAll(&.{ |
| | 477 | if (self.read) 'r' else '-', |
| | 478 | if (self.write) 'w' else '-', |
| | 479 | if (self.execute) 'x' else '-', |
| | 480 | }); |
| | 481 | } |
| 460 | }; | 482 | }; |
| 461 | }; | 483 | }; |
| 462 | }; | 484 | }; |