summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-05-12 21:54:39 +0100
committerGitHub <noreply@github.com>2019-05-12 21:54:39 +0100
commit1e3a639d4af0e8acdf710b74ee7b230c39df84ae (patch)
tree049d9546ddeae27b9b5a723273f462fe6dae4d9f
parent7f562f2c7880dd7a1b29de62b35842971e746158 (diff)
parent336e98bb95393b165bc5f13f3b729cbddf1fd554 (diff)
downloadlibgit2-1e3a639d4af0e8acdf710b74ee7b230c39df84ae.tar.gz
Merge pull request #5065 from danielgindi/feature/win32_symlink_dir
Support symlinks for directories in win32
-rw-r--r--src/win32/posix_w32.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index fcaf77e89..05ac79a16 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -397,13 +397,18 @@ int p_readlink(const char *path, char *buf, size_t bufsiz)
int p_symlink(const char *target, const char *path)
{
git_win32_path target_w, path_w;
+ DWORD dwFlags;
if (git_win32_path_from_utf8(path_w, path) < 0 ||
git__utf8_to_16(target_w, MAX_PATH, target) < 0)
return -1;
- if (!CreateSymbolicLinkW(path_w, target_w,
- SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE))
+ dwFlags = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
+
+ if (GetFileAttributesW(target_w) & FILE_ATTRIBUTE_DIRECTORY)
+ dwFlags |= SYMBOLIC_LINK_FLAG_DIRECTORY;
+
+ if (!CreateSymbolicLinkW(path_w, target_w, dwFlags))
return -1;
return 0;