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. Public Function

relative

Public Function
std.fs.path.relative
pub fn relative(
    gpa: Allocator,
    cwd: []const u8,
    environ_map: ?*const std.process.Environ.Map,
    from: []const u8,
    to: []const u8,
) Allocator.Error![]u8

Returns the non-absolute path from from to to.

Other than memory allocation, this is a pure function; the result solely depends on the input parameters.

If from and to each resolve to the same path (after calling resolve on each), a zero-length string is returned.

See relativePosix and relativeWindows for operating system specific details and for how environ_map is used.

Params

File

fs/path.zig:1511
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
pub fn relative(
    gpa: Allocator,
    cwd: []const u8,
    environ_map: ?*const std.process.Environ.Map,
    from: []const u8,
    to: []const u8,
) Allocator.Error![]u8 {
    if (native_os == .windows) {
        return relativeWindows(gpa, cwd, environ_map, from, to);
    } else {
        return relativePosix(gpa, cwd, from, to);
    }
}