I’m developing a library that manages files and I want the client to ba able to select where the working directory is so it can change the relative paths for opening files. The C++ equivalent is std::filesystem::current_path(working_dir_str); but I can’t find any Zig equivalent.
1 Like
You can use std.os.chdir
to change the current directory.
EDIT:
Renamed to std.posix.chdir
3 Likes
There’s also std.fs.Dir.setAsCwd
if you have a Dir
:
var dir = try std.fs.cwd().openDir("some-path/to/dir", .{});
defer dir.close();
try dir.setAsCwd();
7 Likes