mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-13 01:08:41 -09:00
Fix Dir.fmtPath() when given the root dir
This commit is contained in:
parent
3acab71fce
commit
ba14c0938f
1 changed files with 2 additions and 1 deletions
|
|
@ -237,11 +237,12 @@ pub const Dir = packed struct {
|
||||||
name: u8,
|
name: u8,
|
||||||
|
|
||||||
pub fn fmtPath(self: *const @This(), withRoot: bool, out: *std.ArrayList(u8)) void {
|
pub fn fmtPath(self: *const @This(), withRoot: bool, out: *std.ArrayList(u8)) void {
|
||||||
|
if (!withRoot and self.parent == null) return;
|
||||||
var components = std.ArrayList([:0]const u8).init(main.allocator);
|
var components = std.ArrayList([:0]const u8).init(main.allocator);
|
||||||
defer components.deinit();
|
defer components.deinit();
|
||||||
var it: ?*const @This() = self;
|
var it: ?*const @This() = self;
|
||||||
while (it) |e| : (it = e.parent)
|
while (it) |e| : (it = e.parent)
|
||||||
if (withRoot or e != root)
|
if (withRoot or e.parent != null)
|
||||||
components.append(e.entry.name()) catch unreachable;
|
components.append(e.entry.name()) catch unreachable;
|
||||||
|
|
||||||
var i: usize = components.items.len-1;
|
var i: usize = components.items.len-1;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue