diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 0c7f8f06d5..3cdb163f38 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -1720,12 +1720,12 @@ pub const SymlinkFlags = struct { /// See also `symLinkAbsoluteZ` and `symLinkAbsoluteW`. pub fn symLinkAbsolute(target_path: []const u8, sym_link_path: []const u8, flags: SymlinkFlags) !void { if (builtin.os.tag == .wasi) { - @compileError("symLink is not supported in WASI"); + @compileError("symLinkAbsolute is not supported in WASI"); } assert(path.isAbsolute(target_path)); assert(path.isAbsolute(sym_link_path)); if (builtin.os.tag == .windows) { - return os.windows.CreateSymbolicLink(target_path, sym_link_path, flags.is_directory); + return os.windows.CreateSymbolicLink(sym_link_path, target_path, flags.is_directory); } return os.symlink(target_path, sym_link_path); } @@ -1737,7 +1737,7 @@ pub fn symLinkAbsolute(target_path: []const u8, sym_link_path: []const u8, flags pub fn symLinkAbsoluteW(target_path_w: [*:0]const u16, sym_link_path_w: [*:0]const u16, flags: SymlinkFlags) !void { assert(path.isAbsoluteWindowsW(target_path_w)); assert(path.isAbsoluteWindowsW(sym_link_path_w)); - return os.windows.CreateSymbolicLinkW(target_path_w, sym_link_path_w, flags.is_directory); + return os.windows.CreateSymbolicLinkW(sym_link_path_w, target_path_w, flags.is_directory); } /// 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 if (builtin.os.tag == .windows) { const target_path_w = try os.windows.cStrToWin32PrefixedFileW(target_path_c); const sym_link_path_w = try os.windows.cStrToWin32PrefixedFileW(sym_link_path_c); - return os.windows.CreateSymbolicLinkW(target_path_w.span().ptr, sym_link_path_w.span().ptr, flags.is_directory); + return os.windows.CreateSymbolicLinkW(sym_link_path_w.span().ptr, target_path_w.span().ptr, flags.is_directory); } return os.symlinkZ(target_path_c, sym_link_path_c); } diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index 0d9420d389..c95af79e02 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -27,7 +27,7 @@ test "symlink with relative paths" { try cwd.writeFile("file.txt", "nonsense"); if (builtin.os.tag == .windows) { - try os.windows.CreateSymbolicLink("file.txt", "symlinked", false); + try os.windows.CreateSymbolicLink("symlinked", "file.txt", false); } else { try os.symlink("file.txt", "symlinked"); } diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index 8576acc384..7835742e39 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -602,7 +602,15 @@ pub fn GetCurrentDirectory(buffer: []u8) GetCurrentDirectoryError![]u8 { return buffer[0..end_index]; } -pub const CreateSymbolicLinkError = error{ AccessDenied, PathAlreadyExists, FileNotFound, Unexpected }; +pub const CreateSymbolicLinkError = error{ + AccessDenied, + PathAlreadyExists, + FileNotFound, + NameTooLong, + InvalidUtf8, + BadPathName, + Unexpected +}; pub fn CreateSymbolicLink( sym_link_path: []const u8,