Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Function

dirnameAllowEmpty

Private Function
std.Build.dirnameAllowEmpty
fn dirnameAllowEmpty(full_path: []const u8) ?[]const u8

dirnameAllowEmpty is a variant of fs.path.dirname that allows "" to refer to the root for relative paths.

For context, dirname("foo") and dirname("") are both null. However, for relative paths, we want dirname("foo") to be "" so that we can join it with another path (e.g. build root, cache root, etc.)

dirname("") should still be null, because we can't go up any further.

Params

  • full_path: []const u8

File

Build.zig:2170
2170
2171
2172
2173
2174
2175
2176
fn dirnameAllowEmpty(full_path: []const u8) ?[]const u8 {
    return fs.path.dirname(full_path) orelse {
        if (fs.path.isAbsolute(full_path) or full_path.len == 0) return null;

        return "";
    };
}