summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--win/tclWinFile.c18
-rw-r--r--win/tclWinInit.c3
-rw-r--r--win/tclWinInt.h1
3 files changed, 18 insertions, 4 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index 2967cce..b733ab5 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -264,11 +264,21 @@ WinLink(
TclWinConvertError(GetLastError());
} else if (linkAction & TCL_CREATE_SYMBOLIC_LINK) {
- /*
- * Can't symlink files.
- */
+ if (!tclWinProcs.createSymbolicLink) {
+ /*
+ * Can't symlink files.
+ */
+ Tcl_SetErrno(ENOTDIR);
+ } else if (tclWinProcs.createSymbolicLink(linkSourcePath, linkTargetPath,
+ 0x2 /* SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE */)) {
+ /*
+ * Success!
+ */
- Tcl_SetErrno(ENOTDIR);
+ return 0;
+ }
+
+ TclWinConvertError(GetLastError());
} else {
Tcl_SetErrno(ENODEV);
}
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 6b8f18a..d2f9b2f 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -164,6 +164,9 @@ TclpInitPlatform(void)
tclWinProcs.cancelSynchronousIo =
(BOOL (WINAPI *)(HANDLE))(void *)GetProcAddress(handle,
"CancelSynchronousIo");
+ tclWinProcs.createSymbolicLink =
+ (BOOLEAN (WINAPI *)(LPCWSTR, LPCWSTR, DWORD))(void *)GetProcAddress(handle,
+ "CreateSymbolicLinkW");
}
/*
diff --git a/win/tclWinInt.h b/win/tclWinInt.h
index ac95da5..7aac7d0 100644
--- a/win/tclWinInt.h
+++ b/win/tclWinInt.h
@@ -36,6 +36,7 @@ typedef struct TCLEXCEPTION_REGISTRATION {
*/
typedef struct TclWinProcs {
BOOL (WINAPI *cancelSynchronousIo)(HANDLE);
+ BOOLEAN (WINAPI *createSymbolicLink)(LPCWSTR, LPCWSTR, DWORD);
} TclWinProcs;
MODULE_SCOPE TclWinProcs tclWinProcs;