Get path `[]const u8` from `std.fs.Dir`

I’m trying to get absolute path from std.fs.Dir, can’t see if there something can help me in std. realpath as I understand is checking path to be real, so it adds complexity for my tests (need to create folder structure first).
Is there some way to get absolute path from std.fs.Dir or std.testing.TmpDir?

EDIT: Let’s say not absolute path, but any, so in tests I can compare handwritten path and processed one by my script.

std.fs.Dir is a handle. You need at least one system call to convert the handle to path. realpath, or realpathAlloc looks like the only way.

std.fs.path have path manipulation functions that don’t make syscalls. You might want to rewrite tmpDir using this API.

1 Like

Dir.realpathAlloc(allocator, '.') solved issue.
I forgot that I can just put ‘.’ to specify current directory in relative to Dir.