diff options
| author | Vicent Martà <vicent@github.com> | 2013-02-08 02:50:23 -0800 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2013-02-08 02:50:23 -0800 |
| commit | 5b62eb7dd7dc7301ade96852fd98731755b3da79 (patch) | |
| tree | 6250449c9c284e7fa1300b2806f2743731d7c008 /src | |
| parent | 41713ec15f66d263c2d7d40dd07f1f5a468e3e22 (diff) | |
| parent | 7672c8c779e1a3264db20941b7d9ba1472c0ec94 (diff) | |
| download | libgit2-5b62eb7dd7dc7301ade96852fd98731755b3da79.tar.gz | |
Merge pull request #1325 from SHyx0rmZ/fix-windows-symlinks
Fix Windows symlinks
Diffstat (limited to 'src')
| -rw-r--r-- | src/win32/posix_w32.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c index 0c23e2959..339d43131 100644 --- a/src/win32/posix_w32.c +++ b/src/win32/posix_w32.c @@ -100,6 +100,21 @@ static int do_lstat( buf->st_mtime = filetime_to_time_t(&(fdata.ftLastWriteTime)); buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime)); + /* Windows symlinks have zero file size, call readlink to determine + * the length of the path pointed to, which we expect everywhere else + */ + if (fMode & S_IFLNK) { + char target[GIT_WIN_PATH]; + int readlink_result; + + readlink_result = p_readlink(file_name, target, GIT_WIN_PATH); + + if (readlink_result == -1) + return -1; + + buf->st_size = strlen(target); + } + return 0; } @@ -157,10 +172,10 @@ int p_readlink(const char *link, char *target, size_t target_len) * it is not available in platforms older than Vista */ if (pGetFinalPath == NULL) { - HINSTANCE library = LoadLibrary("kernel32"); + HMODULE module = GetModuleHandle("kernel32"); - if (library != NULL) - pGetFinalPath = (fpath_func)GetProcAddress(library, "GetFinalPathNameByHandleW"); + if (module != NULL) + pGetFinalPath = (fpath_func)GetProcAddress(module, "GetFinalPathNameByHandleW"); if (pGetFinalPath == NULL) { giterr_set(GITERR_OS, |
