Skip to content

Instantly share code, notes, and snippets.

View nitrogenez's full-sized avatar
🇺🇦

Andrij Glyko nitrogenez

🇺🇦
View GitHub Profile
@nitrogenez
nitrogenez / bochs.zig
Created September 20, 2025 11:44
A wrapper for bochsrc to use in build.zig.
const std = @import("std");
pub const Options = std.StringHashMapUnmanaged(?[]const u8);
pub const Rc = struct {
plugin_ctrl: ?Options = null,
config_interface: ?Options = null,
display_library: ?Options = null,
cpu: ?Options = null,
cpuid: ?Options = null,
memory: ?Options = null,
@nitrogenez
nitrogenez / home.zig
Created January 5, 2025 16:01
A simple cross-platform home dir retrieval for Zig 0.13.0 using my PathBuf implementation.
const std = @import("std");
const builtin = @import("builtin");
const fs = std.fs;
const parseInt = std.fmt.parseInt;
pub const PathBuf = @import("PathBuf.zig");
pub fn getHomeOf(user: []const u8) PathBuf {
return if (builtin.os.tag == .windows) getHomeOfW(user) else getHomeOfZ(user);
@nitrogenez
nitrogenez / PathBuf.zig
Created January 5, 2025 15:51
A path buffer implementation inspired by Rust's std::path::PathBuf for Zig 0.13.0. Feel free to copy-paste it into your code.
const std = @import("std");
const builtin = @import("builtin");
const fmt = std.fmt;
const fs = std.fs;
const path = fs.path;
const mem = std.mem;
const testing = std.testing;
buffer: [std.fs.max_path_bytes]u8,