tiny.sandbox.resolve
Defined in tiny.sandbox.
API (2)
Actions
Public operations.
Source
Source: lib/sandbox/src/resolve.zig
zig
const std = @import("std");const sys = @import("sys");const fs_io = sys.fs.debugIo();pub fn dirPath(dir: sys.fs.Dir, buffer: []u8) ![]const u8 { if (dir.handle == std.Io.Dir.cwd().handle) { const len = try std.process.currentPath(fs_io, buffer); return buffer[0..len]; } const len = try dir.realPath(fs_io, buffer); return buffer[0..len];}pub fn dirPathAllocZ(allocator: std.mem.Allocator, dir: sys.fs.Dir) ![:0]u8 { var buffer: [std.fs.max_path_bytes]u8 = undefined; const path = try dirPath(dir, &buffer); return try allocator.dupeSentinel(u8, path, 0);}test "dir path resolves the current working directory pseudo handle" { var buffer: [std.fs.max_path_bytes]u8 = undefined; const resolved = try dirPath(std.Io.Dir.cwd(), &buffer); try std.testing.expect(std.fs.path.isAbsolute(resolved));}test "dir path resolves real directory handles" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); var buffer: [std.fs.max_path_bytes]u8 = undefined; const resolved = try dirPath(tmp.dir, &buffer); try std.testing.expect(std.fs.path.isAbsolute(resolved));}Source: lib/sandbox/src/root.zig:40
zig
pub const resolve = @import("resolve.zig");Audit
| Definitions | 3 |
|---|---|
| Public names | 3 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |