diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2020-07-15 17:55:02 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2020-07-22 08:51:22 +0200 |
| commit | cc9c5c5b0e7c37f96d7ea4c6bd22118ea72a0265 (patch) | |
| tree | 82947e5569da4fcbd0a63e81cc7160000659c1f0 /lib/std/os.zig | |
| parent | a8a02dfbfaf4b9bd303712c853e202bd07837371 (diff) | |
| download | zig-cc9c5c5b0e7c37f96d7ea4c6bd22118ea72a0265.tar.gz zig-cc9c5c5b0e7c37f96d7ea4c6bd22118ea72a0265.zip | |
Handle relative/absolute symlinks; add more tests
Diffstat (limited to 'lib/std/os.zig')
| -rw-r--r-- | lib/std/os.zig | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/std/os.zig b/lib/std/os.zig index 6e614b8006..5243c1155a 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -2437,7 +2437,10 @@ pub fn readlinkW(file_path: [*:0]const u16, out_buffer: []u8) ReadLinkError![]u8 fn parseReadlinkPath(path: []const u16, is_relative: bool, out_buffer: []u8) []u8 { const prefix = [_]u16{ '\\', '?', '?', '\\' }; - const start_index = if (mem.startsWith(u16, path, &prefix)) prefix.len else 0; + var start_index: usize = 0; + if (!is_relative and mem.startsWith(u16, path, &prefix)) { + start_index = prefix.len; + } const out_len = std.unicode.utf16leToUtf8(out_buffer, path[start_index..]) catch unreachable; return out_buffer[0..out_len]; } |
