Zig 0.17.0-dev (Split by item) 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.
std › zig › resolveGlobalCacheDir Public Function resolveGlobalCacheDir Doc Source Public Function std.zig.resolveGlobalCacheDir
pub fn resolveGlobalCacheDir (arena : Allocator , environ_map : *const std .process .Environ .Map ) ![]const u8 Params File zig.zig: 1585
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611 pub fn resolveGlobalCacheDir (arena : Allocator , environ_map : *const std .process .Environ .Map ) ![]const u8 {
if (EnvVar .ZIG_GLOBAL_CACHE_DIR .get (environ_map )) |value | return value ;
const app_name = "zig" ;
switch (builtin .os .tag ) {
.wasi => @compileError ("on WASI the global cache dir must be resolved with preopens" ),
.windows => {
const local_app_data_dir = EnvVar .LOCALAPPDATA .get (environ_map ) orelse
return error .AppDataDirUnavailable ;
return Dir .path .join (arena , &.{ local_app_data_dir , app_name });
},
else => {
if (EnvVar .XDG_CACHE_HOME .get (environ_map )) |cache_root | {
if (cache_root .len > 0 ) {
return Dir .path .join (arena , &.{ cache_root , app_name });
}
}
if (EnvVar .HOME .get (environ_map )) |home | {
if (home .len > 0 ) {
return Dir .path .join (arena , &.{ home , ".cache" , app_name });
}
}
return error .AppDataDirUnavailable ;
},
}
}