Basic module

get_working_directory

procedure · 1 overloadSource

The current working directory of the program, as an absolute path in a new string from context.allocator that the caller frees.

get_working_directory :: () -> result: string

Relative paths given to the file procedures are resolved against it. The path uses the system's own separators. The system cannot give the directory (it was deleted while the program was in it, or it cannot be searched) the result is the empty string, which no working directory is, and there is nothing to free.

Returns

result: string
ExampleOpen in playground ↗
original := get_working_directory();
defer free(original);
assert(original.count > 0);

assert(set_working_directory("."));
same := get_working_directory();
assert(same == original);
free(same);

See also