I’m trying to walk a directory to create a tar file.
I am doing this with the zig build system.
The directory walking API says:
/// Recursively iterates over a directory.
///
/// `self` must have been opened with `OpenOptions{.iterate = true}`.
///
/// `Walker.deinit` releases allocated memory and directory handles.
///
/// The order of returned file system entries is undefined.
///
/// `self` will not be closed after walking it.
///
/// See also `walkSelectively`.
pub fn walk(self: Dir, allocator: Allocator) Allocator.Error!Walker {
return .{
.inner = try walkSelectively(self, allocator),
};
}
The “undefined order” of returned entries is problematic because it will cause my tar file to be non-deterministically created.
How can I I walk a dir to create a tar file reproducibly?