├── .github └── workflows │ ├── lint.yml │ ├── linux.yml │ ├── macos.yml │ └── windows.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.zig ├── docs ├── data.js ├── index.html ├── main.js └── src │ ├── Progress.zig.html │ ├── SemanticVersion.zig.html │ ├── Thread.zig.html │ ├── Thread │ ├── Condition.zig.html │ ├── Futex.zig.html │ ├── Mutex.zig.html │ ├── ResetEvent.zig.html │ ├── RwLock.zig.html │ └── Semaphore.zig.html │ ├── array_hash_map.zig.html │ ├── array_list.zig.html │ ├── ascii.zig.html │ ├── atomic.zig.html │ ├── atomic │ ├── Atomic.zig.html │ ├── queue.zig.html │ └── stack.zig.html │ ├── base64.zig.html │ ├── bit_set.zig.html │ ├── bounded_array.zig.html │ ├── buf_map.zig.html │ ├── buf_set.zig.html │ ├── build.zig.html │ ├── build │ ├── CheckFileStep.zig.html │ ├── CheckObjectStep.zig.html │ ├── EmulatableRunStep.zig.html │ ├── FmtStep.zig.html │ ├── InstallRawStep.zig.html │ ├── OptionsStep.zig.html │ ├── RunStep.zig.html │ ├── TranslateCStep.zig.html │ └── WriteFileStep.zig.html │ ├── builtin.zig.html │ ├── c.zig.html │ ├── c │ └── tokenizer.zig.html │ ├── child_process.zig.html │ ├── coff.zig.html │ ├── compress.zig.html │ ├── compress │ ├── deflate.zig.html │ ├── deflate │ │ ├── bits_utils.zig.html │ │ ├── compressor.zig.html │ │ ├── decompressor.zig.html │ │ ├── deflate_const.zig.html │ │ ├── deflate_fast.zig.html │ │ ├── dict_decoder.zig.html │ │ ├── huffman_bit_writer.zig.html │ │ ├── huffman_code.zig.html │ │ ├── mem_utils.zig.html │ │ └── token.zig.html │ ├── gzip.zig.html │ └── zlib.zig.html │ ├── comptime_string_map.zig.html │ ├── crypto.zig.html │ ├── crypto │ ├── 25519 │ │ ├── curve25519.zig.html │ │ ├── ed25519.zig.html │ │ ├── edwards25519.zig.html │ │ ├── field.zig.html │ │ ├── ristretto255.zig.html │ │ ├── scalar.zig.html │ │ └── x25519.zig.html │ ├── aegis.zig.html │ ├── aes.zig.html │ ├── aes_gcm.zig.html │ ├── aes_ocb.zig.html │ ├── argon2.zig.html │ ├── bcrypt.zig.html │ ├── blake2.zig.html │ ├── blake3.zig.html │ ├── chacha20.zig.html │ ├── ecdsa.zig.html │ ├── errors.zig.html │ ├── ghash.zig.html │ ├── gimli.zig.html │ ├── hash_composition.zig.html │ ├── hkdf.zig.html │ ├── hmac.zig.html │ ├── isap.zig.html │ ├── md5.zig.html │ ├── modes.zig.html │ ├── pbkdf2.zig.html │ ├── pcurves │ │ ├── common.zig.html │ │ ├── p256.zig.html │ │ ├── p256 │ │ │ ├── field.zig.html │ │ │ ├── p256_64.zig.html │ │ │ ├── p256_scalar_64.zig.html │ │ │ └── scalar.zig.html │ │ ├── p384.zig.html │ │ ├── p384 │ │ │ ├── field.zig.html │ │ │ ├── p384_64.zig.html │ │ │ ├── p384_scalar_64.zig.html │ │ │ └── scalar.zig.html │ │ ├── secp256k1.zig.html │ │ └── secp256k1 │ │ │ ├── field.zig.html │ │ │ ├── scalar.zig.html │ │ │ ├── secp256k1_64.zig.html │ │ │ └── secp256k1_scalar_64.zig.html │ ├── phc_encoding.zig.html │ ├── poly1305.zig.html │ ├── salsa20.zig.html │ ├── scrypt.zig.html │ ├── sha1.zig.html │ ├── sha2.zig.html │ ├── sha3.zig.html │ ├── siphash.zig.html │ ├── test.zig.html │ ├── tlcsprng.zig.html │ ├── utils.zig.html │ └── xoodoo.zig.html │ ├── cstr.zig.html │ ├── debug.zig.html │ ├── dwarf.zig.html │ ├── dwarf │ ├── AT.zig.html │ ├── ATE.zig.html │ ├── FORM.zig.html │ ├── LANG.zig.html │ ├── OP.zig.html │ └── TAG.zig.html │ ├── dynamic_library.zig.html │ ├── elf.zig.html │ ├── enums.zig.html │ ├── event.zig.html │ ├── event │ ├── batch.zig.html │ ├── channel.zig.html │ ├── future.zig.html │ ├── group.zig.html │ ├── lock.zig.html │ ├── locked.zig.html │ ├── loop.zig.html │ ├── rwlock.zig.html │ ├── rwlocked.zig.html │ └── wait_group.zig.html │ ├── fifo.zig.html │ ├── fmt.zig.html │ ├── fmt │ ├── errol.zig.html │ ├── errol │ │ ├── enum3.zig.html │ │ └── lookup.zig.html │ ├── parse_float.zig.html │ └── parse_float │ │ ├── FloatInfo.zig.html │ │ ├── FloatStream.zig.html │ │ ├── common.zig.html │ │ ├── convert_eisel_lemire.zig.html │ │ ├── convert_fast.zig.html │ │ ├── convert_hex.zig.html │ │ ├── convert_slow.zig.html │ │ ├── decimal.zig.html │ │ ├── parse.zig.html │ │ └── parse_float.zig.html │ ├── formats │ └── zip │ │ ├── format.zig.html │ │ ├── reader.zig.html │ │ └── writer.zig.html │ ├── fs.zig.html │ ├── fs │ ├── file.zig.html │ ├── get_app_data_dir.zig.html │ ├── path.zig.html │ ├── wasi.zig.html │ └── watch.zig.html │ ├── hash.zig.html │ ├── hash │ ├── adler.zig.html │ ├── auto_hash.zig.html │ ├── cityhash.zig.html │ ├── crc.zig.html │ ├── fnv.zig.html │ ├── murmur.zig.html │ └── wyhash.zig.html │ ├── hash_map.zig.html │ ├── hashing.zig.html │ ├── heap.zig.html │ ├── heap │ ├── arena_allocator.zig.html │ ├── general_purpose_allocator.zig.html │ ├── log_to_writer_allocator.zig.html │ └── logging_allocator.zig.html │ ├── http.zig.html │ ├── http │ ├── method.zig.html │ └── status.zig.html │ ├── io.zig.html │ ├── io │ ├── bit_reader.zig.html │ ├── bit_writer.zig.html │ ├── buffered_atomic_file.zig.html │ ├── buffered_reader.zig.html │ ├── buffered_writer.zig.html │ ├── c_writer.zig.html │ ├── change_detection_stream.zig.html │ ├── counting_reader.zig.html │ ├── counting_writer.zig.html │ ├── find_byte_writer.zig.html │ ├── fixed_buffer_stream.zig.html │ ├── limited_reader.zig.html │ ├── multi_writer.zig.html │ ├── peek_stream.zig.html │ ├── reader.zig.html │ ├── seekable_stream.zig.html │ ├── stream_source.zig.html │ └── writer.zig.html │ ├── json.zig.html │ ├── json │ └── write_stream.zig.html │ ├── leb128.zig.html │ ├── linked_list.zig.html │ ├── log.zig.html │ ├── macho.zig.html │ ├── main.zig.html │ ├── math.zig.html │ ├── math │ ├── acos.zig.html │ ├── acosh.zig.html │ ├── asin.zig.html │ ├── asinh.zig.html │ ├── atan.zig.html │ ├── atan2.zig.html │ ├── atanh.zig.html │ ├── big.zig.html │ ├── big │ │ ├── int.zig.html │ │ └── rational.zig.html │ ├── cbrt.zig.html │ ├── complex.zig.html │ ├── complex │ │ ├── abs.zig.html │ │ ├── acos.zig.html │ │ ├── acosh.zig.html │ │ ├── arg.zig.html │ │ ├── asin.zig.html │ │ ├── asinh.zig.html │ │ ├── atan.zig.html │ │ ├── atanh.zig.html │ │ ├── conj.zig.html │ │ ├── cos.zig.html │ │ ├── cosh.zig.html │ │ ├── exp.zig.html │ │ ├── ldexp.zig.html │ │ ├── log.zig.html │ │ ├── pow.zig.html │ │ ├── proj.zig.html │ │ ├── sin.zig.html │ │ ├── sinh.zig.html │ │ ├── sqrt.zig.html │ │ ├── tan.zig.html │ │ └── tanh.zig.html │ ├── copysign.zig.html │ ├── cosh.zig.html │ ├── expm1.zig.html │ ├── expo2.zig.html │ ├── float.zig.html │ ├── frexp.zig.html │ ├── gcd.zig.html │ ├── hypot.zig.html │ ├── ilogb.zig.html │ ├── isfinite.zig.html │ ├── isinf.zig.html │ ├── isnan.zig.html │ ├── isnormal.zig.html │ ├── ldexp.zig.html │ ├── ln.zig.html │ ├── log.zig.html │ ├── log10.zig.html │ ├── log1p.zig.html │ ├── log2.zig.html │ ├── modf.zig.html │ ├── nan.zig.html │ ├── pow.zig.html │ ├── powi.zig.html │ ├── scalbn.zig.html │ ├── signbit.zig.html │ ├── sinh.zig.html │ ├── sqrt.zig.html │ └── tanh.zig.html │ ├── mem.zig.html │ ├── mem │ └── Allocator.zig.html │ ├── meta.zig.html │ ├── meta │ ├── trailer_flags.zig.html │ └── trait.zig.html │ ├── multi_array_list.zig.html │ ├── net.zig.html │ ├── once.zig.html │ ├── os.zig.html │ ├── os │ ├── darwin.zig.html │ ├── linux.zig.html │ ├── linux │ │ ├── bpf.zig.html │ │ ├── bpf │ │ │ ├── btf.zig.html │ │ │ ├── btf_ext.zig.html │ │ │ └── kern.zig.html │ │ ├── ioctl.zig.html │ │ ├── seccomp.zig.html │ │ ├── start_pie.zig.html │ │ ├── syscalls.zig.html │ │ ├── tls.zig.html │ │ └── vdso.zig.html │ ├── plan9.zig.html │ ├── posix_spawn.zig.html │ ├── uefi.zig.html │ ├── uefi │ │ ├── pool_allocator.zig.html │ │ ├── protocols.zig.html │ │ ├── protocols │ │ │ └── hii.zig.html │ │ ├── status.zig.html │ │ └── tables.zig.html │ ├── wasi.zig.html │ ├── windows.zig.html │ └── windows │ │ ├── advapi32.zig.html │ │ ├── gdi32.zig.html │ │ ├── kernel32.zig.html │ │ ├── lang.zig.html │ │ ├── ntdll.zig.html │ │ ├── ntstatus.zig.html │ │ ├── ole32.zig.html │ │ ├── psapi.zig.html │ │ ├── shell32.zig.html │ │ ├── sublang.zig.html │ │ ├── user32.zig.html │ │ ├── win32error.zig.html │ │ ├── winmm.zig.html │ │ └── ws2_32.zig.html │ ├── packed_int_array.zig.html │ ├── pdb.zig.html │ ├── priority_dequeue.zig.html │ ├── priority_queue.zig.html │ ├── process.zig.html │ ├── rand.zig.html │ ├── rand │ ├── Isaac64.zig.html │ ├── Pcg.zig.html │ ├── RomuTrio.zig.html │ ├── Sfc64.zig.html │ ├── Xoodoo.zig.html │ ├── Xoroshiro128.zig.html │ ├── Xoshiro256.zig.html │ └── ziggurat.zig.html │ ├── segmented_list.zig.html │ ├── simd.zig.html │ ├── sort.zig.html │ ├── start.zig.html │ ├── std.zig.html │ ├── target.zig.html │ ├── target │ ├── aarch64.zig.html │ ├── amdgpu.zig.html │ ├── arc.zig.html │ ├── arm.zig.html │ ├── avr.zig.html │ ├── bpf.zig.html │ ├── csky.zig.html │ ├── hexagon.zig.html │ ├── m68k.zig.html │ ├── mips.zig.html │ ├── msp430.zig.html │ ├── nvptx.zig.html │ ├── powerpc.zig.html │ ├── riscv.zig.html │ ├── s390x.zig.html │ ├── sparc.zig.html │ ├── spirv.zig.html │ ├── ve.zig.html │ ├── wasm.zig.html │ └── x86.zig.html │ ├── test_runner.zig.html │ ├── testing.zig.html │ ├── testing │ └── failing_allocator.zig.html │ ├── time.zig.html │ ├── time │ └── epoch.zig.html │ ├── treap.zig.html │ ├── tz.zig.html │ ├── unicode.zig.html │ ├── valgrind.zig.html │ ├── valgrind │ ├── callgrind.zig.html │ └── memcheck.zig.html │ ├── wasm.zig.html │ ├── x.zig.html │ ├── x │ ├── net │ │ ├── bpf.zig.html │ │ ├── ip.zig.html │ │ └── tcp.zig.html │ └── os │ │ ├── net.zig.html │ │ └── socket.zig.html │ ├── zig.zig.html │ └── zig │ ├── Ast.zig.html │ ├── CrossTarget.zig.html │ ├── c_builtins.zig.html │ ├── c_translation.zig.html │ ├── fmt.zig.html │ ├── number_literal.zig.html │ ├── parse.zig.html │ ├── string_literal.zig.html │ ├── system.zig.html │ ├── system │ ├── NativePaths.zig.html │ ├── NativeTargetInfo.zig.html │ ├── darwin.zig.html │ ├── darwin │ │ └── macos.zig.html │ ├── linux.zig.html │ └── windows.zig.html │ └── tokenizer.zig.html ├── src ├── formats │ └── zip │ │ ├── format.zig │ │ ├── reader.zig │ │ └── writer.zig ├── hashing.zig ├── main.zig └── seekable_buffered_stream.zig └── tests ├── bench_zip.zig ├── benchmark.zig ├── read_zip.zig └── write_zip.zig /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | push: 5 | paths: 6 | - "**.zig" 7 | pull_request: 8 | paths: 9 | - "**.zig" 10 | schedule: 11 | - cron: "0 0 * * *" 12 | workflow_dispatch: 13 | 14 | jobs: 15 | lint: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v2 20 | 21 | - name: Setup Zig 22 | uses: goto-bus-stop/setup-zig@v1 23 | with: 24 | version: master 25 | 26 | - name: Lint Source 27 | run: zig fmt src 28 | 29 | - name: Lint Build 30 | run: zig fmt build.zig -------------------------------------------------------------------------------- /.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | name: Linux 2 | 3 | on: 4 | push: 5 | paths: 6 | - "**.zig" 7 | pull_request: 8 | paths: 9 | - "**.zig" 10 | schedule: 11 | - cron: "0 0 * * *" 12 | workflow_dispatch: 13 | 14 | jobs: 15 | test: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v2 20 | 21 | - name: Setup Zig 22 | uses: goto-bus-stop/setup-zig@v1 23 | with: 24 | version: master 25 | 26 | - name: Download 27 | run: | 28 | mkdir tests/zip 29 | curl -fLo tests/zip/zig-windows.zip https://github.com/ziglang/zig/archive/refs/heads/master.zip 30 | curl -fLo tests/zip/zig-windows-release.zip https://ziglang.org/download/0.9.0/zig-windows-x86_64-0.9.0.zip 31 | 32 | - name: Write Zip 33 | run: zig build write_zip 34 | 35 | - name: Read Zip 36 | run: zig build read_zip 37 | -------------------------------------------------------------------------------- /.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | name: MacOS 2 | 3 | on: 4 | push: 5 | paths: 6 | - "**.zig" 7 | pull_request: 8 | paths: 9 | - "**.zig" 10 | schedule: 11 | - cron: "0 0 * * *" 12 | workflow_dispatch: 13 | 14 | jobs: 15 | test: 16 | runs-on: macos-latest 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v2 20 | 21 | - name: Setup Zig 22 | uses: goto-bus-stop/setup-zig@v1 23 | with: 24 | version: master 25 | 26 | - name: Download 27 | run: | 28 | mkdir tests/zip 29 | curl -fLo tests/zip/zig-windows.zip https://github.com/ziglang/zig/archive/refs/heads/master.zip 30 | curl -fLo tests/zip/zig-windows-release.zip https://ziglang.org/download/0.9.0/zig-windows-x86_64-0.9.0.zip 31 | 32 | - name: Write Zip 33 | run: zig build write_zip 34 | 35 | - name: Read Zip 36 | run: zig build read_zip 37 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: Windows 2 | 3 | on: 4 | push: 5 | paths: 6 | - "**.zig" 7 | pull_request: 8 | paths: 9 | - "**.zig" 10 | schedule: 11 | - cron: "0 0 * * *" 12 | workflow_dispatch: 13 | 14 | jobs: 15 | test: 16 | runs-on: windows-latest 17 | steps: 18 | - name: Disable CRLF 19 | run: | 20 | git config --global core.autocrlf false 21 | git config --global core.eol lf 22 | - name: Checkout 23 | uses: actions/checkout@v2 24 | 25 | - name: Setup Zig 26 | uses: goto-bus-stop/setup-zig@v1 27 | with: 28 | version: master 29 | 30 | - name: Download 31 | run: | 32 | mkdir tests/zip 33 | curl -fLo tests/zip/zig-windows.zip https://github.com/ziglang/zig/archive/refs/heads/master.zip 34 | curl -fLo tests/zip/zig-windows-release.zip https://ziglang.org/download/0.9.0/zig-windows-x86_64-0.9.0.zip 35 | 36 | - name: Write Zip 37 | run: zig build write_zip 38 | 39 | - name: Read Zip 40 | run: zig build read_zip 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | zig-cache/ 2 | zig-out/ 3 | 4 | tests/extract 5 | tests/zip 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 truemedian 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # zig-archive 3 | 4 | [![Linux Workflow Status](https://img.shields.io/github/workflow/status/truemedian/zig-archive/Linux?label=Linux&style=for-the-badge)](https://github.com/truemedian/zig-archive/actions/workflows/linux.yml) 5 | [![Windows Workflow Status](https://img.shields.io/github/workflow/status/truemedian/zig-archive/Windows?label=Windows&style=for-the-badge)](https://github.com/truemedian/zig-archive/actions/workflows/windows.yml) 6 | [![MacOS Workflow Status](https://img.shields.io/github/workflow/status/truemedian/zig-archive/MacOS?label=MacOS&style=for-the-badge)](https://github.com/truemedian/zig-archive/actions/workflows/macos.yml) 7 | 8 | Reading and writing archives in zig. 9 | 10 | ## Features 11 | 12 | - Reading and writing zip archives 13 | - Supports zip64 14 | - Supports zip files with a preamble (like self-extracting archives) 15 | - TODO: Reading and writing tar archives 16 | 17 | ## Examples 18 | 19 | Reading (and extracting) a zip archive: tests/read_zip.zig 20 | 21 | Writing a zip archive: tests/write_zip.zig 22 | -------------------------------------------------------------------------------- /build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | const Builder = std.build.Builder; 4 | 5 | const tests = .{ 6 | "read_zip", 7 | "write_zip", 8 | }; 9 | 10 | const bench = .{ 11 | "bench_zip", 12 | }; 13 | 14 | pub fn build(b: *Builder) void { 15 | const optimize = b.standardOptimizeOption(.{}); 16 | 17 | b.addModule(.{ 18 | .name = "archive", 19 | .source_file = .{ .path = "src/main.zig" }, 20 | }); 21 | const archive_module = b.modules.get("archive") orelse unreachable; 22 | 23 | // Library Tests 24 | 25 | const lib_tests = b.addTest(.{ 26 | .root_source_file = .{ .path = "src/main.zig" }, 27 | .optimize = optimize, 28 | }); 29 | 30 | const lib_tests_step = b.step("test", "Run all library tests"); 31 | lib_tests_step.dependOn(&lib_tests.step); 32 | 33 | const docs = b.option(bool, "emit_docs", "Build library documentation") orelse false; 34 | 35 | if (docs) 36 | lib_tests.emit_docs = .emit; 37 | 38 | // Test Runners 39 | 40 | inline for (tests) |file| { 41 | const zip_runner = b.addExecutable(.{ 42 | .name = file, 43 | .root_source_file = .{ .path = "tests/" ++ file ++ ".zig" }, 44 | .optimize = optimize, 45 | }); 46 | zip_runner.linkLibC(); 47 | 48 | zip_runner.addModule("archive", archive_module); 49 | 50 | zip_runner.install(); 51 | const run_zip_runner = zip_runner.run(); 52 | 53 | const run_tests = b.step(file, "Run tests"); 54 | run_tests.dependOn(&run_zip_runner.step); 55 | } 56 | 57 | // Benchmarks 58 | 59 | const preallocate = b.option(bool, "preallocate", "Allocate the file into memory rather than reading from disk [true].") orelse true; 60 | const void_write = b.option(bool, "void_write", "Write to a void file rather than a real file when extracting [true].") orelse true; 61 | const runtime = b.option(u32, "runtime", "How long to run benchmarks in seconds [60].") orelse 60; 62 | 63 | const bench_options = b.addOptions(); 64 | bench_options.addOption(bool, "preallocate", preallocate); 65 | bench_options.addOption(bool, "void_write", void_write); 66 | bench_options.addOption(u32, "runtime", runtime); 67 | 68 | inline for (bench) |file| { 69 | const zip_bench = b.addExecutable(.{ 70 | .name = file, 71 | .root_source_file = .{ .path = "tests/" ++ file ++ ".zig" }, 72 | .optimize = optimize, 73 | }); 74 | zip_bench.addOptions("build_options", bench_options); 75 | zip_bench.addModule("archive", archive_module); 76 | 77 | zip_bench.install(); 78 | const run_zip_bench = zip_bench.run(); 79 | 80 | const zip_bench_step = b.step(file, "Run benchmark"); 81 | zip_bench_step.dependOn(&run_zip_bench.step); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /docs/src/build/FmtStep.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | build/FmtStep.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../std.zig");
115 | const build = @import("../build.zig");
116 | const Step = build.Step;
117 | const Builder = build.Builder;
118 | const BufMap = std.BufMap;
119 | const mem = std.mem;
120 | 
121 | const FmtStep = @This();
122 | 
123 | pub const base_id = .fmt;
124 | 
125 | step: Step,
126 | builder: *Builder,
127 | argv: [][]const u8,
128 | 
129 | pub fn create(builder: *Builder, paths: []const []const u8) *FmtStep {
130 |     const self = builder.allocator.create(FmtStep) catch unreachable;
131 |     const name = "zig fmt";
132 |     self.* = FmtStep{
133 |         .step = Step.init(.fmt, name, builder.allocator, make),
134 |         .builder = builder,
135 |         .argv = builder.allocator.alloc([]u8, paths.len + 2) catch unreachable,
136 |     };
137 | 
138 |     self.argv[0] = builder.zig_exe;
139 |     self.argv[1] = "fmt";
140 |     for (paths) |path, i| {
141 |         self.argv[2 + i] = builder.pathFromRoot(path);
142 |     }
143 |     return self;
144 | }
145 | 
146 | fn make(step: *Step) !void {
147 |     const self = @fieldParentPtr(FmtStep, "step", step);
148 | 
149 |     return self.builder.spawnChild(self.argv);
150 | }
151 | 
152 | 
153 | -------------------------------------------------------------------------------- /docs/src/compress.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | compress.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("std.zig");
115 | 
116 | pub const deflate = @import("compress/deflate.zig");
117 | pub const gzip = @import("compress/gzip.zig");
118 | pub const zlib = @import("compress/zlib.zig");
119 | 
120 | test {
121 |     _ = deflate;
122 |     _ = gzip;
123 |     _ = zlib;
124 | }
125 | 
126 | 
127 | -------------------------------------------------------------------------------- /docs/src/compress/deflate.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | compress/deflate.zig - source view 6 | 7 | 112 | 113 | 114 |
//! The deflate package is a translation of the Go code of the compress/flate package from
115 | //! https://go.googlesource.com/go/+/refs/tags/go1.17/src/compress/flate/
116 | 
117 | const deflate = @import("deflate/compressor.zig");
118 | const inflate = @import("deflate/decompressor.zig");
119 | 
120 | pub const Compression = deflate.Compression;
121 | pub const CompressorOptions = deflate.CompressorOptions;
122 | pub const Compressor = deflate.Compressor;
123 | pub const Decompressor = inflate.Decompressor;
124 | 
125 | pub const compressor = deflate.compressor;
126 | pub const decompressor = inflate.decompressor;
127 | 
128 | test {
129 |     _ = @import("deflate/token.zig");
130 |     _ = @import("deflate/bits_utils.zig");
131 |     _ = @import("deflate/dict_decoder.zig");
132 | 
133 |     _ = @import("deflate/huffman_code.zig");
134 |     _ = @import("deflate/huffman_bit_writer.zig");
135 | 
136 |     _ = @import("deflate/compressor.zig");
137 |     _ = @import("deflate/compressor_test.zig");
138 | 
139 |     _ = @import("deflate/deflate_fast.zig");
140 |     _ = @import("deflate/deflate_fast_test.zig");
141 | 
142 |     _ = @import("deflate/decompressor.zig");
143 | }
144 | 
145 | 
146 | -------------------------------------------------------------------------------- /docs/src/compress/deflate/deflate_const.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | compress/deflate/deflate_const.zig - source view 6 | 7 | 112 | 113 | 114 |
// Deflate
115 | 
116 | 
117 | // Biggest block size for uncompressed block.
118 | 
119 | pub const max_store_block_size = 65535;
120 | // The special code used to mark the end of a block.
121 | 
122 | pub const end_block_marker = 256;
123 | 
124 | // LZ77
125 | 
126 | 
127 | // The smallest match length per the RFC section 3.2.5
128 | 
129 | pub const base_match_length = 3;
130 | // The smallest match offset.
131 | 
132 | pub const base_match_offset = 1;
133 | // The largest match length.
134 | 
135 | pub const max_match_length = 258;
136 | // The largest match offset.
137 | 
138 | pub const max_match_offset = 1 << 15;
139 | 
140 | // Huffman Codes
141 | 
142 | 
143 | // The largest offset code.
144 | 
145 | pub const offset_code_count = 30;
146 | // Max number of frequencies used for a Huffman Code
147 | 
148 | // Possible lengths are codegenCodeCount (19), offset_code_count (30) and max_num_lit (286).
149 | 
150 | // The largest of these is max_num_lit.
151 | 
152 | pub const max_num_frequencies = max_num_lit;
153 | // Maximum number of literals.
154 | 
155 | pub const max_num_lit = 286;
156 | 
157 | 
158 | -------------------------------------------------------------------------------- /docs/src/compress/deflate/mem_utils.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | compress/deflate/mem_utils.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("std");
115 | const math = std.math;
116 | const mem = std.mem;
117 | 
118 | // Copies elements from a source `src` slice into a destination `dst` slice.
119 | 
120 | // The copy never returns an error but might not be complete if the destination is too small.
121 | 
122 | // Returns the number of elements copied, which will be the minimum of `src.len` and `dst.len`.
123 | 
124 | pub fn copy(dst: []u8, src: []const u8) usize {
125 |     if (dst.len <= src.len) {
126 |         mem.copy(u8, dst[0..], src[0..dst.len]);
127 |     } else {
128 |         mem.copy(u8, dst[0..src.len], src[0..]);
129 |     }
130 |     return math.min(dst.len, src.len);
131 | }
132 | 
133 | 
134 | -------------------------------------------------------------------------------- /docs/src/crypto/pcurves/p256/field.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | crypto/pcurves/p256/field.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("std");
115 | const common = @import("../common.zig");
116 | 
117 | const Field = common.Field;
118 | 
119 | pub const Fe = Field(.{
120 |     .fiat = @import("p256_64.zig"),
121 |     .field_order = 115792089210356248762697446949407573530086143415290314195533631308867097853951,
122 |     .field_bits = 256,
123 |     .saturated_bits = 256,
124 |     .encoded_length = 32,
125 | });
126 | 
127 | 
128 | -------------------------------------------------------------------------------- /docs/src/crypto/pcurves/p384/field.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | crypto/pcurves/p384/field.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("std");
115 | const common = @import("../common.zig");
116 | 
117 | const Field = common.Field;
118 | 
119 | pub const Fe = Field(.{
120 |     .fiat = @import("p384_64.zig"),
121 |     .field_order = 39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319,
122 |     .field_bits = 384,
123 |     .saturated_bits = 384,
124 |     .encoded_length = 48,
125 | });
126 | 
127 | 
128 | -------------------------------------------------------------------------------- /docs/src/crypto/pcurves/secp256k1/field.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | crypto/pcurves/secp256k1/field.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("std");
115 | const common = @import("../common.zig");
116 | 
117 | const Field = common.Field;
118 | 
119 | pub const Fe = Field(.{
120 |     .fiat = @import("secp256k1_64.zig"),
121 |     .field_order = 115792089237316195423570985008687907853269984665640564039457584007908834671663,
122 |     .field_bits = 256,
123 |     .saturated_bits = 256,
124 |     .encoded_length = 32,
125 | });
126 | 
127 | 
128 | -------------------------------------------------------------------------------- /docs/src/crypto/test.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | crypto/test.zig - source view 6 | 7 | 112 | 113 | 114 |

115 | 
116 | -------------------------------------------------------------------------------- /docs/src/http.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | http.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("std.zig");
115 | 
116 | pub const Method = @import("http/method.zig").Method;
117 | pub const Status = @import("http/status.zig").Status;
118 | 
119 | test {
120 |     std.testing.refAllDecls(@This());
121 | }
122 | 
123 | 
124 | -------------------------------------------------------------------------------- /docs/src/main.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | main.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("std");
115 | 
116 | pub const formats = struct {
117 |     pub const zip = struct {
118 |         pub const reader = @import("formats/zip/reader.zig");
119 |         pub const writer = @import("formats/zip/writer.zig");
120 | 
121 |         pub const internal = @import("formats/zip/format.zig");
122 |     };
123 | };
124 | 
125 | comptime {
126 |     std.testing.refAllDecls(formats);
127 | }
128 | 
129 | 
130 | -------------------------------------------------------------------------------- /docs/src/math/big.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/big.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../std.zig");
115 | const assert = std.debug.assert;
116 | 
117 | pub const Rational = @import("big/rational.zig").Rational;
118 | pub const int = @import("big/int.zig");
119 | pub const Limb = usize;
120 | const limb_info = @typeInfo(Limb).Int;
121 | pub const SignedLimb = std.meta.Int(.signed, limb_info.bits);
122 | pub const DoubleLimb = std.meta.Int(.unsigned, 2 * limb_info.bits);
123 | pub const HalfLimb = std.meta.Int(.unsigned, limb_info.bits / 2);
124 | pub const SignedDoubleLimb = std.meta.Int(.signed, 2 * limb_info.bits);
125 | pub const Log2Limb = std.math.Log2Int(Limb);
126 | 
127 | comptime {
128 |     assert(std.math.floorPowerOfTwo(usize, limb_info.bits) == limb_info.bits);
129 |     assert(limb_info.bits <= 64); // u128 set is unsupported
130 | 
131 |     assert(limb_info.signedness == .unsigned);
132 | }
133 | 
134 | test {
135 |     _ = int;
136 |     _ = Rational;
137 |     _ = Limb;
138 |     _ = SignedLimb;
139 |     _ = DoubleLimb;
140 |     _ = SignedDoubleLimb;
141 |     _ = Log2Limb;
142 | }
143 | 
144 | 
145 | -------------------------------------------------------------------------------- /docs/src/math/complex/abs.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/abs.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns the absolute value (modulus) of z.
121 | pub fn abs(z: anytype) @TypeOf(z.re) {
122 |     const T = @TypeOf(z.re);
123 |     return math.hypot(T, z.re, z.im);
124 | }
125 | 
126 | const epsilon = 0.0001;
127 | 
128 | test "complex.cabs" {
129 |     const a = Complex(f32).init(5, 3);
130 |     const c = abs(a);
131 |     try testing.expect(math.approxEqAbs(f32, c, 5.83095, epsilon));
132 | }
133 | 
134 | 
135 | -------------------------------------------------------------------------------- /docs/src/math/complex/acos.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/acos.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns the arc-cosine of z.
121 | pub fn acos(z: anytype) Complex(@TypeOf(z.re)) {
122 |     const T = @TypeOf(z.re);
123 |     const q = cmath.asin(z);
124 |     return Complex(T).init(@as(T, math.pi) / 2 - q.re, -q.im);
125 | }
126 | 
127 | const epsilon = 0.0001;
128 | 
129 | test "complex.cacos" {
130 |     const a = Complex(f32).init(5, 3);
131 |     const c = acos(a);
132 | 
133 |     try testing.expect(math.approxEqAbs(f32, c.re, 0.546975, epsilon));
134 |     try testing.expect(math.approxEqAbs(f32, c.im, -2.452914, epsilon));
135 | }
136 | 
137 | 
138 | -------------------------------------------------------------------------------- /docs/src/math/complex/acosh.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/acosh.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns the hyperbolic arc-cosine of z.
121 | pub fn acosh(z: anytype) Complex(@TypeOf(z.re)) {
122 |     const T = @TypeOf(z.re);
123 |     const q = cmath.acos(z);
124 |     return Complex(T).init(-q.im, q.re);
125 | }
126 | 
127 | const epsilon = 0.0001;
128 | 
129 | test "complex.cacosh" {
130 |     const a = Complex(f32).init(5, 3);
131 |     const c = acosh(a);
132 | 
133 |     try testing.expect(math.approxEqAbs(f32, c.re, 2.452914, epsilon));
134 |     try testing.expect(math.approxEqAbs(f32, c.im, 0.546975, epsilon));
135 | }
136 | 
137 | 
138 | -------------------------------------------------------------------------------- /docs/src/math/complex/arg.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/arg.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns the angular component (in radians) of z.
121 | pub fn arg(z: anytype) @TypeOf(z.re) {
122 |     const T = @TypeOf(z.re);
123 |     return math.atan2(T, z.im, z.re);
124 | }
125 | 
126 | const epsilon = 0.0001;
127 | 
128 | test "complex.carg" {
129 |     const a = Complex(f32).init(5, 3);
130 |     const c = arg(a);
131 |     try testing.expect(math.approxEqAbs(f32, c, 0.540420, epsilon));
132 | }
133 | 
134 | 
135 | -------------------------------------------------------------------------------- /docs/src/math/complex/asin.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/asin.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | // Returns the arc-sine of z.
121 | 
122 | pub fn asin(z: anytype) Complex(@TypeOf(z.re)) {
123 |     const T = @TypeOf(z.re);
124 |     const x = z.re;
125 |     const y = z.im;
126 | 
127 |     const p = Complex(T).init(1.0 - (x - y) * (x + y), -2.0 * x * y);
128 |     const q = Complex(T).init(-y, x);
129 |     const r = cmath.log(q.add(cmath.sqrt(p)));
130 | 
131 |     return Complex(T).init(r.im, -r.re);
132 | }
133 | 
134 | const epsilon = 0.0001;
135 | 
136 | test "complex.casin" {
137 |     const a = Complex(f32).init(5, 3);
138 |     const c = asin(a);
139 | 
140 |     try testing.expect(math.approxEqAbs(f32, c.re, 1.023822, epsilon));
141 |     try testing.expect(math.approxEqAbs(f32, c.im, 2.452914, epsilon));
142 | }
143 | 
144 | 
145 | -------------------------------------------------------------------------------- /docs/src/math/complex/asinh.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/asinh.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns the hyperbolic arc-sine of z.
121 | pub fn asinh(z: anytype) Complex(@TypeOf(z.re)) {
122 |     const T = @TypeOf(z.re);
123 |     const q = Complex(T).init(-z.im, z.re);
124 |     const r = cmath.asin(q);
125 |     return Complex(T).init(r.im, -r.re);
126 | }
127 | 
128 | const epsilon = 0.0001;
129 | 
130 | test "complex.casinh" {
131 |     const a = Complex(f32).init(5, 3);
132 |     const c = asinh(a);
133 | 
134 |     try testing.expect(math.approxEqAbs(f32, c.re, 2.459831, epsilon));
135 |     try testing.expect(math.approxEqAbs(f32, c.im, 0.533999, epsilon));
136 | }
137 | 
138 | 
139 | -------------------------------------------------------------------------------- /docs/src/math/complex/atanh.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/atanh.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns the hyperbolic arc-tangent of z.
121 | pub fn atanh(z: anytype) Complex(@TypeOf(z.re)) {
122 |     const T = @TypeOf(z.re);
123 |     const q = Complex(T).init(-z.im, z.re);
124 |     const r = cmath.atan(q);
125 |     return Complex(T).init(r.im, -r.re);
126 | }
127 | 
128 | const epsilon = 0.0001;
129 | 
130 | test "complex.catanh" {
131 |     const a = Complex(f32).init(5, 3);
132 |     const c = atanh(a);
133 | 
134 |     try testing.expect(math.approxEqAbs(f32, c.re, 0.146947, epsilon));
135 |     try testing.expect(math.approxEqAbs(f32, c.im, 1.480870, epsilon));
136 | }
137 | 
138 | 
139 | -------------------------------------------------------------------------------- /docs/src/math/complex/conj.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/conj.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns the complex conjugate of z.
121 | pub fn conj(z: anytype) Complex(@TypeOf(z.re)) {
122 |     const T = @TypeOf(z.re);
123 |     return Complex(T).init(z.re, -z.im);
124 | }
125 | 
126 | test "complex.conj" {
127 |     const a = Complex(f32).init(5, 3);
128 |     const c = a.conjugate();
129 | 
130 |     try testing.expect(c.re == 5 and c.im == -3);
131 | }
132 | 
133 | 
134 | -------------------------------------------------------------------------------- /docs/src/math/complex/cos.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/cos.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns the cosine of z.
121 | pub fn cos(z: anytype) Complex(@TypeOf(z.re)) {
122 |     const T = @TypeOf(z.re);
123 |     const p = Complex(T).init(-z.im, z.re);
124 |     return cmath.cosh(p);
125 | }
126 | 
127 | const epsilon = 0.0001;
128 | 
129 | test "complex.ccos" {
130 |     const a = Complex(f32).init(5, 3);
131 |     const c = cos(a);
132 | 
133 |     try testing.expect(math.approxEqAbs(f32, c.re, 2.855815, epsilon));
134 |     try testing.expect(math.approxEqAbs(f32, c.im, 9.606383, epsilon));
135 | }
136 | 
137 | 
138 | -------------------------------------------------------------------------------- /docs/src/math/complex/log.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/log.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns the natural logarithm of z.
121 | pub fn log(z: anytype) Complex(@TypeOf(z.re)) {
122 |     const T = @TypeOf(z.re);
123 |     const r = cmath.abs(z);
124 |     const phi = cmath.arg(z);
125 | 
126 |     return Complex(T).init(@log(r), phi);
127 | }
128 | 
129 | const epsilon = 0.0001;
130 | 
131 | test "complex.clog" {
132 |     const a = Complex(f32).init(5, 3);
133 |     const c = log(a);
134 | 
135 |     try testing.expect(math.approxEqAbs(f32, c.re, 1.763180, epsilon));
136 |     try testing.expect(math.approxEqAbs(f32, c.im, 0.540419, epsilon));
137 | }
138 | 
139 | 
140 | -------------------------------------------------------------------------------- /docs/src/math/complex/pow.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/pow.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns z raised to the complex power of c.
121 | pub fn pow(comptime T: type, z: T, c: T) T {
122 |     const p = cmath.log(z);
123 |     const q = c.mul(p);
124 |     return cmath.exp(q);
125 | }
126 | 
127 | const epsilon = 0.0001;
128 | 
129 | test "complex.cpow" {
130 |     const a = Complex(f32).init(5, 3);
131 |     const b = Complex(f32).init(2.3, -1.3);
132 |     const c = pow(Complex(f32), a, b);
133 | 
134 |     try testing.expect(math.approxEqAbs(f32, c.re, 58.049110, epsilon));
135 |     try testing.expect(math.approxEqAbs(f32, c.im, -101.003433, epsilon));
136 | }
137 | 
138 | 
139 | -------------------------------------------------------------------------------- /docs/src/math/complex/proj.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/proj.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns the projection of z onto the riemann sphere.
121 | pub fn proj(z: anytype) Complex(@TypeOf(z.re)) {
122 |     const T = @TypeOf(z.re);
123 | 
124 |     if (math.isInf(z.re) or math.isInf(z.im)) {
125 |         return Complex(T).init(math.inf(T), math.copysign(@as(T, 0.0), z.re));
126 |     }
127 | 
128 |     return Complex(T).init(z.re, z.im);
129 | }
130 | 
131 | const epsilon = 0.0001;
132 | 
133 | test "complex.cproj" {
134 |     const a = Complex(f32).init(5, 3);
135 |     const c = proj(a);
136 | 
137 |     try testing.expect(c.re == 5 and c.im == 3);
138 | }
139 | 
140 | 
141 | -------------------------------------------------------------------------------- /docs/src/math/complex/sin.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/sin.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns the sine of z.
121 | pub fn sin(z: anytype) Complex(@TypeOf(z.re)) {
122 |     const T = @TypeOf(z.re);
123 |     const p = Complex(T).init(-z.im, z.re);
124 |     const q = cmath.sinh(p);
125 |     return Complex(T).init(q.im, -q.re);
126 | }
127 | 
128 | const epsilon = 0.0001;
129 | 
130 | test "complex.csin" {
131 |     const a = Complex(f32).init(5, 3);
132 |     const c = sin(a);
133 | 
134 |     try testing.expect(math.approxEqAbs(f32, c.re, -9.654126, epsilon));
135 |     try testing.expect(math.approxEqAbs(f32, c.im, 2.841692, epsilon));
136 | }
137 | 
138 | 
139 | -------------------------------------------------------------------------------- /docs/src/math/complex/tan.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/complex/tan.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const testing = std.testing;
116 | const math = std.math;
117 | const cmath = math.complex;
118 | const Complex = cmath.Complex;
119 | 
120 | /// Returns the tanget of z.
121 | pub fn tan(z: anytype) Complex(@TypeOf(z.re)) {
122 |     const T = @TypeOf(z.re);
123 |     const q = Complex(T).init(-z.im, z.re);
124 |     const r = cmath.tanh(q);
125 |     return Complex(T).init(r.im, -r.re);
126 | }
127 | 
128 | const epsilon = 0.0001;
129 | 
130 | test "complex.ctan" {
131 |     const a = Complex(f32).init(5, 3);
132 |     const c = tan(a);
133 | 
134 |     try testing.expect(math.approxEqAbs(f32, c.re, -0.002708233, epsilon));
135 |     try testing.expect(math.approxEqAbs(f32, c.im, 1.004165, epsilon));
136 | }
137 | 
138 | 
139 | -------------------------------------------------------------------------------- /docs/src/math/isnan.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/isnan.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../std.zig");
115 | const math = std.math;
116 | const expect = std.testing.expect;
117 | const maxInt = std.math.maxInt;
118 | 
119 | /// Returns whether x is a nan.
120 | pub fn isNan(x: anytype) bool {
121 |     return x != x;
122 | }
123 | 
124 | /// Returns whether x is a signalling nan.
125 | pub fn isSignalNan(x: anytype) bool {
126 |     // Note: A signalling nan is identical to a standard nan right now but may have a different bit
127 | 
128 |     // representation in the future when required.
129 | 
130 |     return isNan(x);
131 | }
132 | 
133 | test "math.isNan" {
134 |     try expect(isNan(math.nan(f16)));
135 |     try expect(isNan(math.nan(f32)));
136 |     try expect(isNan(math.nan(f64)));
137 |     try expect(isNan(math.nan(f128)));
138 |     try expect(!isNan(@as(f16, 1.0)));
139 |     try expect(!isNan(@as(f32, 1.0)));
140 |     try expect(!isNan(@as(f64, 1.0)));
141 |     try expect(!isNan(@as(f128, 1.0)));
142 | }
143 | 
144 | 
145 | -------------------------------------------------------------------------------- /docs/src/math/log10.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/log10.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../std.zig");
115 | const math = std.math;
116 | const testing = std.testing;
117 | const maxInt = std.math.maxInt;
118 | 
119 | /// Returns the base-10 logarithm of x.
120 | ///
121 | /// Special Cases:
122 | ///  - log10(+inf)  = +inf
123 | ///  - log10(0)     = -inf
124 | ///  - log10(x)     = nan if x < 0
125 | ///  - log10(nan)   = nan
126 | pub fn log10(x: anytype) @TypeOf(x) {
127 |     const T = @TypeOf(x);
128 |     switch (@typeInfo(T)) {
129 |         .ComptimeFloat => {
130 |             return @as(comptime_float, @log10(x));
131 |         },
132 |         .Float => return @log10(x),
133 |         .ComptimeInt => {
134 |             return @as(comptime_int, @floor(@log10(@as(f64, x))));
135 |         },
136 |         .Int => |IntType| switch (IntType.signedness) {
137 |             .signed => @compileError("log10 not implemented for signed integers"),
138 |             .unsigned => return @floatToInt(T, @floor(@log10(@intToFloat(f64, x)))),
139 |         },
140 |         else => @compileError("log10 not implemented for " ++ @typeName(T)),
141 |     }
142 | }
143 | 
144 | 
145 | -------------------------------------------------------------------------------- /docs/src/math/nan.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/nan.zig - source view 6 | 7 | 112 | 113 | 114 |
const math = @import("../math.zig");
115 | 
116 | /// Returns the nan representation for type T.
117 | pub inline fn nan(comptime T: type) T {
118 |     return switch (@typeInfo(T).Float.bits) {
119 |         16 => math.nan_f16,
120 |         32 => math.nan_f32,
121 |         64 => math.nan_f64,
122 |         80 => math.nan_f80,
123 |         128 => math.nan_f128,
124 |         else => @compileError("unreachable"),
125 |     };
126 | }
127 | 
128 | /// Returns the signalling nan representation for type T.
129 | /// Note: A signalling nan is identical to a standard right now by may have a different bit
130 | /// representation in the future when required.
131 | pub inline fn snan(comptime T: type) T {
132 |     return nan(T);
133 | }
134 | 
135 | 
136 | -------------------------------------------------------------------------------- /docs/src/math/scalbn.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/scalbn.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("std");
115 | const expect = std.testing.expect;
116 | 
117 | /// Returns a * FLT_RADIX ^ exp.
118 | ///
119 | /// Zig only supports binary radix IEEE-754 floats. Hence FLT_RADIX=2, and this is an alias for ldexp.
120 | pub const scalbn = @import("ldexp.zig").ldexp;
121 | 
122 | test "math.scalbn" {
123 |     // Verify we are using radix 2.
124 | 
125 |     try expect(scalbn(@as(f16, 1.5), 4) == 24.0);
126 |     try expect(scalbn(@as(f32, 1.5), 4) == 24.0);
127 |     try expect(scalbn(@as(f64, 1.5), 4) == 24.0);
128 |     try expect(scalbn(@as(f128, 1.5), 4) == 24.0);
129 | }
130 | 
131 | 
132 | -------------------------------------------------------------------------------- /docs/src/math/signbit.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | math/signbit.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../std.zig");
115 | const math = std.math;
116 | const expect = std.testing.expect;
117 | 
118 | /// Returns whether x is negative or negative 0.
119 | pub fn signbit(x: anytype) bool {
120 |     const T = @TypeOf(x);
121 |     const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
122 |     return @bitCast(TBits, x) >> (@bitSizeOf(T) - 1) != 0;
123 | }
124 | 
125 | test "math.signbit" {
126 |     inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| {
127 |         try expect(!signbit(@as(T, 0.0)));
128 |         try expect(!signbit(@as(T, 1.0)));
129 |         try expect(signbit(@as(T, -2.0)));
130 |         try expect(signbit(@as(T, -0.0)));
131 |         try expect(!signbit(math.inf(T)));
132 |         try expect(signbit(-math.inf(T)));
133 |         try expect(!signbit(math.nan(T)));
134 |         try expect(signbit(-math.nan(T)));
135 |     }
136 | }
137 | 
138 | 
139 | -------------------------------------------------------------------------------- /docs/src/os/linux/bpf/btf_ext.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | os/linux/bpf/btf_ext.zig - source view 6 | 7 | 112 | 113 | 114 |
pub const Header = packed struct {
115 |     magic: u16,
116 |     version: u8,
117 |     flags: u8,
118 |     hdr_len: u32,
119 | 
120 |     /// All offsets are in bytes relative to the end of this header
121 |     func_info_off: u32,
122 |     func_info_len: u32,
123 |     line_info_off: u32,
124 |     line_info_len: u32,
125 | };
126 | 
127 | pub const InfoSec = packed struct {
128 |     sec_name_off: u32,
129 |     num_info: u32,
130 |     // TODO: communicate that there is data here
131 | 
132 |     //data: [0]u8,
133 | 
134 | };
135 | 
136 | 
137 | -------------------------------------------------------------------------------- /docs/src/os/uefi/tables.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | os/uefi/tables.zig - source view 6 | 7 | 112 | 113 | 114 |
pub usingnamespace @import("tables/boot_services.zig");
115 | pub usingnamespace @import("tables/runtime_services.zig");
116 | pub usingnamespace @import("tables/configuration_table.zig");
117 | pub usingnamespace @import("tables/system_table.zig");
118 | pub usingnamespace @import("tables/table_header.zig");
119 | 
120 | 
121 | -------------------------------------------------------------------------------- /docs/src/os/windows/advapi32.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | os/windows/advapi32.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const windows = std.os.windows;
116 | const BOOL = windows.BOOL;
117 | const DWORD = windows.DWORD;
118 | const HKEY = windows.HKEY;
119 | const BYTE = windows.BYTE;
120 | const LPCWSTR = windows.LPCWSTR;
121 | const LSTATUS = windows.LSTATUS;
122 | const REGSAM = windows.REGSAM;
123 | const ULONG = windows.ULONG;
124 | const WINAPI = windows.WINAPI;
125 | 
126 | pub extern "advapi32" fn RegOpenKeyExW(
127 |     hKey: HKEY,
128 |     lpSubKey: LPCWSTR,
129 |     ulOptions: DWORD,
130 |     samDesired: REGSAM,
131 |     phkResult: *HKEY,
132 | ) callconv(WINAPI) LSTATUS;
133 | 
134 | pub extern "advapi32" fn RegQueryValueExW(
135 |     hKey: HKEY,
136 |     lpValueName: LPCWSTR,
137 |     lpReserved: *DWORD,
138 |     lpType: *DWORD,
139 |     lpData: *BYTE,
140 |     lpcbData: *DWORD,
141 | ) callconv(WINAPI) LSTATUS;
142 | 
143 | // RtlGenRandom is known as SystemFunction036 under advapi32
144 | 
145 | // http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx */
146 | 
147 | pub extern "advapi32" fn SystemFunction036(output: [*]u8, length: ULONG) callconv(WINAPI) BOOL;
148 | pub const RtlGenRandom = SystemFunction036;
149 | 
150 | 
151 | -------------------------------------------------------------------------------- /docs/src/os/windows/ole32.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | os/windows/ole32.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const windows = std.os.windows;
116 | const WINAPI = windows.WINAPI;
117 | const LPVOID = windows.LPVOID;
118 | const DWORD = windows.DWORD;
119 | const HRESULT = windows.HRESULT;
120 | 
121 | pub extern "ole32" fn CoTaskMemFree(pv: LPVOID) callconv(WINAPI) void;
122 | pub extern "ole32" fn CoUninitialize() callconv(WINAPI) void;
123 | pub extern "ole32" fn CoGetCurrentProcess() callconv(WINAPI) DWORD;
124 | pub extern "ole32" fn CoInitializeEx(pvReserved: ?LPVOID, dwCoInit: DWORD) callconv(WINAPI) HRESULT;
125 | 
126 | 
127 | -------------------------------------------------------------------------------- /docs/src/os/windows/shell32.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | os/windows/shell32.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("../../std.zig");
115 | const windows = std.os.windows;
116 | const WINAPI = windows.WINAPI;
117 | const KNOWNFOLDERID = windows.KNOWNFOLDERID;
118 | const DWORD = windows.DWORD;
119 | const HANDLE = windows.HANDLE;
120 | const WCHAR = windows.WCHAR;
121 | const HRESULT = windows.HRESULT;
122 | 
123 | pub extern "shell32" fn SHGetKnownFolderPath(
124 |     rfid: *const KNOWNFOLDERID,
125 |     dwFlags: DWORD,
126 |     hToken: ?HANDLE,
127 |     ppszPath: *[*:0]WCHAR,
128 | ) callconv(WINAPI) HRESULT;
129 | 
130 | 
131 | -------------------------------------------------------------------------------- /docs/src/x.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | x.zig - source view 6 | 7 | 112 | 113 | 114 |
const std = @import("std.zig");
115 | 
116 | pub const os = struct {
117 |     pub const Socket = @import("x/os/socket.zig").Socket;
118 |     pub usingnamespace @import("x/os/io.zig");
119 |     pub usingnamespace @import("x/os/net.zig");
120 | };
121 | 
122 | pub const net = struct {
123 |     pub const ip = @import("x/net/ip.zig");
124 |     pub const tcp = @import("x/net/tcp.zig");
125 |     pub const bpf = @import("x/net/bpf.zig");
126 | };
127 | 
128 | test {
129 |     inline for (.{ os, net }) |module| {
130 |         std.testing.refAllDecls(module);
131 |     }
132 | }
133 | 
134 | 
135 | -------------------------------------------------------------------------------- /docs/src/zig/system.zig.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | zig/system.zig - source view 6 | 7 | 112 | 113 | 114 |
pub const NativePaths = @import("system/NativePaths.zig");
115 | pub const NativeTargetInfo = @import("system/NativeTargetInfo.zig");
116 | 
117 | pub const windows = @import("system/windows.zig");
118 | pub const darwin = @import("system/darwin.zig");
119 | pub const linux = @import("system/linux.zig");
120 | 
121 | test {
122 |     _ = NativePaths;
123 |     _ = NativeTargetInfo;
124 | 
125 |     _ = darwin;
126 |     _ = linux;
127 |     _ = windows;
128 | }
129 | 
130 | 
131 | -------------------------------------------------------------------------------- /src/hashing.zig: -------------------------------------------------------------------------------- 1 | pub const std = @import("std"); 2 | 3 | pub fn HashingWriter(comptime WriterType: type, comptime Crc32: type) type { 4 | return struct { 5 | const Self = @This(); 6 | 7 | pub const WriteError = WriterType.Error; 8 | 9 | sink: WriterType, 10 | hash: Crc32, 11 | 12 | pub const Writer = std.io.Writer(*Self, WriteError, write); 13 | 14 | pub fn init(writer_: WriterType) Self { 15 | return .{ 16 | .sink = writer_, 17 | .hash = Crc32.init(), 18 | }; 19 | } 20 | 21 | pub fn writer(self: *Self) Writer { 22 | return .{ .context = self }; 23 | } 24 | 25 | pub fn write(self: *Self, bytes: []const u8) WriteError!usize { 26 | const nwrit = try self.sink.write(bytes); 27 | self.hash.update(bytes[0..nwrit]); 28 | return nwrit; 29 | } 30 | }; 31 | } 32 | 33 | pub fn HashingReader(comptime ReaderType: type, comptime Crc32: type) type { 34 | return struct { 35 | const Self = @This(); 36 | 37 | pub const ReadError = ReaderType.Error; 38 | 39 | src: ReaderType, 40 | hash: Crc32, 41 | 42 | pub const Reader = std.io.Reader(*Self, ReadError, read); 43 | 44 | pub fn init(reader_: ReaderType) Self { 45 | return .{ 46 | .src = reader_, 47 | .hash = Crc32.init(), 48 | }; 49 | } 50 | 51 | pub fn reader(self: *Self) Reader { 52 | return .{ .context = self }; 53 | } 54 | 55 | pub fn read(self: *Self, bytes: []u8) ReadError!usize { 56 | const nread = try self.src.read(bytes); 57 | self.hash.update(bytes[0..nread]); 58 | return nread; 59 | } 60 | }; 61 | } 62 | -------------------------------------------------------------------------------- /src/main.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | pub const formats = struct { 4 | pub const zip = struct { 5 | pub const reader = @import("formats/zip/reader.zig"); 6 | pub const writer = @import("formats/zip/writer.zig"); 7 | 8 | pub const internal = @import("formats/zip/format.zig"); 9 | }; 10 | }; 11 | 12 | comptime { 13 | std.testing.refAllDecls(formats); 14 | } 15 | -------------------------------------------------------------------------------- /src/seekable_buffered_stream.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | pub fn mixin(comptime ReaderType: type, comptime SeekerType: type) type { 4 | const ReaderCtx = std.meta.fieldInfo(ReaderType, .context).type; 5 | const SeekerTypeCtx = std.meta.fieldInfo(SeekerType, .context).type; 6 | 7 | if (ReaderCtx != SeekerTypeCtx) 8 | @compileError("ReaderType and SeekerType must have the same context type"); 9 | 10 | return struct { 11 | pub const BufferedReader = std.io.BufferedReader(8192, ReaderType); 12 | 13 | pub inline fn buffered(reader: ReaderType) BufferedReader { 14 | return BufferedReader{ .unbuffered_reader = reader }; 15 | } 16 | 17 | pub fn seekBy(seeker: SeekerType, buffer: *BufferedReader, offset: i64) !void { 18 | if (offset == 0) return; 19 | 20 | const count = if (buffer.start > buffer.end) 21 | buffer.buf.len - buffer.start + buffer.end 22 | else 23 | buffer.end - buffer.start; 24 | 25 | if (offset > 0) { 26 | const u_offset = @intCast(u64, offset); 27 | 28 | if (u_offset <= count) { 29 | buffer.start += u_offset; 30 | if (buffer.start > buffer.buf.len) 31 | buffer.start %= buffer.buf.len; 32 | } else if (u_offset <= count + buffer.buf.len) { 33 | const left = u_offset - count; 34 | 35 | buffer.start = buffer.end; 36 | try buffer.reader().skipBytes(left, .{ .buf_size = 8192 }); 37 | } else { 38 | const left = u_offset - count; 39 | 40 | buffer.start = buffer.end; 41 | try seeker.seekBy(@intCast(i64, left)); 42 | } 43 | } else { 44 | const left = offset - @intCast(i64, count); 45 | 46 | buffer.start = buffer.end; 47 | try seeker.seekBy(left); 48 | } 49 | } 50 | 51 | pub fn getPos(seeker: SeekerType, buffer: *BufferedReader) !u64 { 52 | const pos = try seeker.getPos(); 53 | 54 | const count = if (buffer.start > buffer.end) 55 | buffer.buf.len - buffer.start + buffer.end 56 | else 57 | buffer.end - buffer.start; 58 | 59 | return pos - count; 60 | } 61 | 62 | pub fn seekTo(seeker: SeekerType, buffer: *BufferedReader, pos: u64) !void { 63 | const offset = @intCast(i64, pos) - @intCast(i64, try getPos(seeker, buffer)); 64 | 65 | try seeker.seekBy(buffer, offset); 66 | } 67 | 68 | pub const LimitedReader = struct { 69 | unlimited_reader: BufferedReader.Reader, 70 | limit: usize, 71 | pos: usize = 0, 72 | 73 | pub const Error = BufferedReader.Reader.Error; 74 | pub const Reader = std.io.Reader(*Self, Error, read); 75 | 76 | const Self = @This(); 77 | 78 | pub fn init(unlimited_reader: BufferedReader.Reader, limit: usize) Self { 79 | return .{ 80 | .unlimited_reader = unlimited_reader, 81 | .limit = limit, 82 | }; 83 | } 84 | 85 | fn read(self: *Self, dest: []u8) Error!usize { 86 | if (self.pos >= self.limit) return 0; 87 | 88 | const left = std.math.min(self.limit - self.pos, dest.len); 89 | const num_read = try self.unlimited_reader.read(dest[0..left]); 90 | self.pos += num_read; 91 | 92 | return num_read; 93 | } 94 | 95 | pub fn reader(self: *Self) Reader { 96 | return .{ .context = self }; 97 | } 98 | }; 99 | }; 100 | } 101 | -------------------------------------------------------------------------------- /tests/read_zip.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const archive = @import("archive"); 3 | 4 | const alloc = std.heap.page_allocator; 5 | 6 | pub fn main() !void { 7 | const in_dir = try std.fs.cwd().openIterableDir("tests/zip", .{}); 8 | var it = in_dir.iterate(); 9 | 10 | while (try it.next()) |entry| { 11 | const fd = try in_dir.dir.openFile(entry.name, .{}); 12 | defer fd.close(); 13 | 14 | const str = try fd.readToEndAlloc(alloc, 1024 * 1024 * 1024); 15 | defer alloc.free(str); 16 | 17 | var stream = std.io.fixedBufferStream(@as([]const u8, str)); 18 | var source = std.io.StreamSource{ .const_buffer = stream }; 19 | 20 | var arc = archive.formats.zip.reader.ArchiveReader.init(alloc, &source); 21 | defer arc.deinit(); 22 | 23 | // Load 24 | 25 | try arc.load(); 26 | 27 | // Extract 28 | 29 | for (0..arc.directory.items.len) |j| { 30 | const hdr = arc.getHeader(j); 31 | 32 | if (hdr.uncompressed_size > 0) { 33 | const out = std.io.null_writer; 34 | 35 | try arc.extractFile(hdr, out, true); 36 | } 37 | } 38 | 39 | std.debug.print( 40 | \\name: {s} 41 | \\size: {d} 42 | \\directory: {d} items, {d} bytes, {d} bytes of filenames 43 | \\ 44 | \\ 45 | , .{ 46 | entry.name, 47 | try source.getEndPos(), 48 | arc.directory.items.len, 49 | arc.directory_size, 50 | arc.filename_buf.items.len, 51 | }); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /tests/write_zip.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const archive = @import("archive"); 3 | 4 | const alloc = std.heap.c_allocator; 5 | 6 | pub fn main() !void { 7 | try std.fs.cwd().makePath("tests/zip"); 8 | 9 | const file = try std.fs.cwd().createFile("tests/zip/test.zip", .{}); 10 | defer file.close(); 11 | 12 | var stream = std.io.StreamSource{ .file = file }; 13 | 14 | var arc = archive.formats.zip.writer.ArchiveWriter.init(alloc, &stream); 15 | defer arc.deinit(); 16 | 17 | var i: usize = 0; 18 | while (i < 100000) : (i += 1) { 19 | const name = try std.fmt.allocPrint(alloc, "test{}.txt", .{i}); 20 | defer alloc.free(name); 21 | 22 | try arc.writeString(name, "aaaa", false); 23 | } 24 | 25 | try arc.finish(); 26 | } 27 | --------------------------------------------------------------------------------