SquashFS reading in pure Zig

This is a project I’d like to show off that demonstrates the ease of incrementally porting a project from C to Zig: squashfuse-zig

It started as bindings to squashfuse, which is written in pure C. Function by function, I dumb-ported the logic directly and then slowly re-factored the code using Zig features until eventually all the C code was replaced with idiomatic Zig. Porting actually made the build process much simpler and while it isn’t back to 100% parity with the original project, it is very competitive speed-wise and has support for several decompressors for most algorithms (such as zlib, which can use libz, libdeflate or Zig stdlib)

13 Likes

Excellent!

Btw, I found a typo: squashfuse-zig/example/src/main.zig at 659a7b1acb0f7fdbc9c06ec1a08e6f3f78b71280 · mgord9518/squashfuse-zig · GitHub

2 Likes

That’s awesome!