authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-07-19 12:21:46+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-07-22 08:51:22+02:00
log3c8ceb674eb00ac0a70d6a0742234ce520eccf06
treeb98b93c9e3bb2aea91d53a1318207fc4167412a2
parentfc7d87fef19964273eb65e8cee05eaffa7a9e72f

Fix Windows build


3 files changed, 14 insertions(+), 6 deletions(-)

lib/std/fs.zig+4-4
......@@ -1720,12 +1720,12 @@ pub const SymlinkFlags = struct {
17201720/// See also `symLinkAbsoluteZ` and `symLinkAbsoluteW`.
17211721pub fn symLinkAbsolute(target_path: []const u8, sym_link_path: []const u8, flags: SymlinkFlags) !void {
17221722 if (builtin.os.tag == .wasi) {
1723 @compileError("symLink is not supported in WASI");
1723 @compileError("symLinkAbsolute is not supported in WASI");
17241724 }
17251725 assert(path.isAbsolute(target_path));
17261726 assert(path.isAbsolute(sym_link_path));
17271727 if (builtin.os.tag == .windows) {
1728 return os.windows.CreateSymbolicLink(target_path, sym_link_path, flags.is_directory);
1728 return os.windows.CreateSymbolicLink(sym_link_path, target_path, flags.is_directory);
17291729 }
17301730 return os.symlink(target_path, sym_link_path);
17311731}
......@@ -1737,7 +1737,7 @@ pub fn symLinkAbsolute(target_path: []const u8, sym_link_path: []const u8, flags
17371737pub fn symLinkAbsoluteW(target_path_w: [*:0]const u16, sym_link_path_w: [*:0]const u16, flags: SymlinkFlags) !void {
17381738 assert(path.isAbsoluteWindowsW(target_path_w));
17391739 assert(path.isAbsoluteWindowsW(sym_link_path_w));
1740 return os.windows.CreateSymbolicLinkW(target_path_w, sym_link_path_w, flags.is_directory);
1740 return os.windows.CreateSymbolicLinkW(sym_link_path_w, target_path_w, flags.is_directory);
17411741}
17421742
17431743/// Same as `symLinkAbsolute` except the parameters are null-terminated pointers.
......@@ -1748,7 +1748,7 @@ pub fn symLinkAbsoluteZ(target_path_c: [*:0]const u8, sym_link_path_c: [*:0]cons
17481748 if (builtin.os.tag == .windows) {
17491749 const target_path_w = try os.windows.cStrToWin32PrefixedFileW(target_path_c);
17501750 const sym_link_path_w = try os.windows.cStrToWin32PrefixedFileW(sym_link_path_c);
1751 return os.windows.CreateSymbolicLinkW(target_path_w.span().ptr, sym_link_path_w.span().ptr, flags.is_directory);
1751 return os.windows.CreateSymbolicLinkW(sym_link_path_w.span().ptr, target_path_w.span().ptr, flags.is_directory);
17521752 }
17531753 return os.symlinkZ(target_path_c, sym_link_path_c);
17541754}
lib/std/os/test.zig+1-1
......@@ -27,7 +27,7 @@ test "symlink with relative paths" {
2727 try cwd.writeFile("file.txt", "nonsense");
2828
2929 if (builtin.os.tag == .windows) {
30 try os.windows.CreateSymbolicLink("file.txt", "symlinked", false);
30 try os.windows.CreateSymbolicLink("symlinked", "file.txt", false);
3131 } else {
3232 try os.symlink("file.txt", "symlinked");
3333 }
lib/std/os/windows.zig+9-1
......@@ -602,7 +602,15 @@ pub fn GetCurrentDirectory(buffer: []u8) GetCurrentDirectoryError![]u8 {
602602 return buffer[0..end_index];
603603}
604604
605pub const CreateSymbolicLinkError = error{ AccessDenied, PathAlreadyExists, FileNotFound, Unexpected };
605pub const CreateSymbolicLinkError = error{
606 AccessDenied,
607 PathAlreadyExists,
608 FileNotFound,
609 NameTooLong,
610 InvalidUtf8,
611 BadPathName,
612 Unexpected
613};
606614
607615pub fn CreateSymbolicLink(
608616 sym_link_path: []const u8,