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 › WindowsSdk › MsvcLibDir › libDirFromInstallationPath Private Function libDirFromInstallationPath Doc Source Private Function std.zig.WindowsSdk.MsvcLibDir.libDirFromInstallationPath
fn libDirFromInstallationPath (
gpa : Allocator ,
io : Io ,
installation_path : []const u8 ,
arch : std .Target .Cpu .Arch ,
) error Params File zig/WindowsSdk.zig: 883
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924 fn libDirFromInstallationPath (
gpa : Allocator ,
io : Io ,
installation_path : []const u8 ,
arch : std .Target .Cpu .Arch ,
) error { OutOfMemory , PathNotFound }![]const u8 {
var lib_dir_buf = try std .array_list .Managed (u8 ).initCapacity (gpa , installation_path .len + 64 );
errdefer lib_dir_buf .deinit ();
lib_dir_buf .appendSliceAssumeCapacity (installation_path );
if (!Dir .path .isSep (lib_dir_buf .last ().?)) {
try lib_dir_buf .append ('\\' );
}
const installation_path_with_trailing_sep_len = lib_dir_buf .items .len ;
try lib_dir_buf .appendSlice ("VC\\Auxiliary\\Build\\Microsoft.VCToolsVersion.default.txt" );
var default_tools_version_buf : [512 ]u8 = undefined ;
const default_tools_version_contents = Dir .cwd ().readFile (io , lib_dir_buf .items , &default_tools_version_buf ) catch {
return error .PathNotFound ;
};
var tokenizer = std .mem .tokenizeAny (u8 , default_tools_version_contents , " \r\n" );
const default_tools_version = tokenizer .next () orelse return error .PathNotFound ;
lib_dir_buf .shrinkRetainingCapacity (installation_path_with_trailing_sep_len );
try lib_dir_buf .appendSlice ("VC\\Tools\\MSVC\\" );
try lib_dir_buf .appendSlice (default_tools_version );
try lib_dir_buf .appendSlice ("\\Lib\\" );
try lib_dir_buf .appendSlice (switch (arch ) {
.thumb => "arm" ,
.aarch64 => "arm64" ,
.x86 => "x86" ,
.x86_64 => "x64" ,
else => unreachable ,
});
if (!verifyLibDir (io , lib_dir_buf .items )) {
return error .PathNotFound ;
}
return lib_dir_buf .toOwnedSlice ();
}