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

addPrefixedPathPostContents

Public Function
std.Build.Cache.Manifest.addPrefixedPathPostContents
pub fn addPrefixedPathPostContents(
        man: *Manifest,
        prefixed_path: PrefixedPath,
        bytes: []const u8,
        stat: File.Stat,
    ) !bool

Low level function. prefixed_path references cloned memory. Returns whether or not prefixed_path.sub_path should be kept.

Params

File

Build/Cache.zig:1050
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
    pub fn addPrefixedPathPostContents(
        man: *Manifest,
        prefixed_path: PrefixedPath,
        bytes: []const u8,
        stat: File.Stat,
    ) !bool {
        const gpa = man.cache.gpa;
        const gop = try man.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{});
        errdefer _ = man.files.pop();

        if (gop.found_existing) return false;

        const new_file = gop.key_ptr;

        new_file.* = .{
            .prefixed_path = prefixed_path,
            .max_file_size = null,
            .handle = null,
            .stat = stat,
            .bin_digest = undefined,
            .contents = null,
        };

        if (try man.isProblematicTimestamp(new_file.stat.mtime)) {
            // The actual file has an unreliable timestamp, force it to be hashed
            new_file.stat.mtime = .zero;
            new_file.stat.inode = 0;
        }

        {
            var hasher = hasher_init;
            hasher.update(bytes);
            hasher.final(&new_file.bin_digest);
        }

        man.hash.hasher.update(&new_file.bin_digest);
        return true;
    }