Manages zig-cache
directories. This is not a general-purpose cache. It is designed to be fast and simple, not to withstand attacks using specially-crafted input.
Fields
gpa: Allocator,
hash: HashHelper = .{ },
recent_problematic_timestamp: i128 = 0,
This value is accessed from multiple threads, protected by mutex.
prefixes_buffer: [4]Directory = undefined,
A set of strings such as the zig library directory or project source root, which are stripped from the file paths before putting into the cache. They are replaced with single-character indicators. This is not to save space but to eliminate absolute file paths. This improves portability and usefulness of the cache for advanced use cases.
prefixes_len: usize = 0,
Functions
fn readSmallFile(dir: fs.Dir, sub_path: []const u8, buffer: []u8) ![]u8
On operating systems that support symlinks, does a readlink. On other operating …
On operating systems that support symlinks, does a readlink. On other operating systems, uses the file contents. Windows supports symlinks but only with elevated privileges, so it is treated as not supporting symlinks.
fn writeSmallFile(dir: fs.Dir, sub_path: []const u8, data: []const u8) !void
On operating systems that support symlinks, does a symlink. On other operating s…
On operating systems that support symlinks, does a symlink. On other operating systems, uses the file contents. Windows supports symlinks but only with elevated privileges, so it is treated as not supporting symlinks.
data
must be a valid UTF-8 encoded file path and 255 bytes or fewer.
Values
Hasher | undefined | The type used for hashing file contents. Currently, this is SipHash128(1, 3), be… |
bin_digest_len | comptime_int | This is 128 bits - Even with 2^54 cache entries, the probably of a collision wou… |
hasher_init | Hasher | Initial state with random bytes, that can be copied. Refresh this with new rand… |
hex_digest_len | type |