Functions
fn dirname(path: []const u8) ?[]const u8
Strip the last component from a file path.
Strip the last component from a file path.
If the path is a file in the current directory (no directory component) then returns null.
If the path is the root directory, returns null.
fn extension(path: []const u8) []const u8
Searches for a file extension separated by a
.
and returns the string after th…Searches for a file extension separated by a
.
and returns the string after that.
. Files that end or start with.
and have no other.
in their name are considered to have no extension, in which case this returns “”. Examples:"main.zig"
⇒".zig"
"src/main.zig"
⇒".zig"
".gitignore"
⇒""
".image.png"
⇒".png"
"keep."
⇒"."
"src.keep.me"
⇒".me"
"/src/keep.me"
⇒".me"
"/src/keep.me/"
⇒".me"
The returned slice is guaranteed to have its pointer within the start and end pointer address range ofpath
, even if it is length zero.
fn join(allocator: Allocator, paths: []const []const u8) ![]u8
Naively combines a series of paths with the native path separator. Allocates me…
Naively combines a series of paths with the native path separator. Allocates memory for the result, which must be freed by the caller.
fn joinZ(allocator: Allocator, paths: []const []const u8) ![:0]u8
Naively combines a series of paths with the native path separator and null termi…
Naively combines a series of paths with the native path separator and null terminator. Allocates memory for the result, which must be freed by the caller.
fn relative(allocator: Allocator, from: []const u8, to: []const u8) ![]u8
Returns the relative path from
from
toto
. Iffrom
andto
each resolve …Returns the relative path from
from
toto
. Iffrom
andto
each resolve to the same path (after callingresolve
on each), a zero-length string is returned. On Windows this canonicalizes the drive to a capital letter and paths to\\
.fn relativePosix(allocator: Allocator, from: []const u8, to: []const u8) ![]u8
No documentation provided.
fn relativeWindows(allocator: Allocator, from: []const u8, to: []const u8) ![]u8
No documentation provided.
fn resolve(allocator: Allocator, paths: []const []const u8) ![]u8
On Windows, this calls
resolveWindows
and on POSIX it callsresolvePosix
.fn resolvePosix(allocator: Allocator, paths: []const []const u8) Allocator.Error![]u8
This function is like a series of
cd
statements executed one after another. I…This function is like a series of
cd
statements executed one after another. It resolves “.” and “..”, but will not convert relative path to absolute path, use std.fs.Dir.realpath instead. The result does not have a trailing path separator. This function does not perform any syscalls. Executing this series of path lookups on the actual filesystem may produce different results due to symlinks.fn resolveWindows(allocator: Allocator, paths: []const []const u8) ![]u8
This function is like a series of
cd
statements executed one after another. I…This function is like a series of
cd
statements executed one after another. It resolves “.” and “..”, but will not convert relative path to absolute path, use std.fs.Dir.realpath instead. The result does not have a trailing path separator. Each drive has its own current working directory. Path separators are canonicalized to ‘\’ and drives are canonicalized to capital letters. Note: all usage of this function should be audited due to the existence of symlinks. Without performing actual syscalls, resolving..
could be incorrect. This API may break in the future: https://github.com/ziglang/zig/issues/13613fn stem(path: []const u8) []const u8
Returns the last component of this path without its extension (if any):
- “hell…
Returns the last component of this path without its extension (if any):
- “hello/world/lib.tar.gz” ⇒ “lib.tar”
- “hello/world/lib.tar” ⇒ “lib”
- “hello/world/lib” ⇒ “lib”
Values
NativeUtf8ComponentIterator | undefined | |
delimiter | type | |
delimiter_posix | comptime_int | |
delimiter_windows | comptime_int | |
sep | type | |
sep_posix | comptime_int | |
sep_str | type | |
sep_str_posix | *const [1:0]u8 | |
sep_str_windows | *const [1:0]u8 | |
sep_windows | comptime_int |