aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/eval/funcs.c5
-rw-r--r--src/nvim/os/fs.c24
2 files changed, 28 insertions, 1 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 6d67279e64..b4a3e29156 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -6709,7 +6709,10 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr)
rettv->v_type = VAR_STRING;
const char *fname = tv_get_string(&argvars[0]);
#ifdef WIN32
- char *const v = os_resolve_shortcut(fname);
+ char *v = os_resolve_shortcut(fname);
+ if (v == NULL) {
+ v = os_realpath(fname, v);
+ }
rettv->vval.v_string = (char_u *)(v == NULL ? xstrdup(fname) : v);
#else
# ifdef HAVE_READLINK
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index ae922e4040..e06762383f 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -1147,6 +1147,30 @@ bool os_fileid_equal_fileinfo(const FileID *file_id,
&& file_id->device_id == file_info->stat.st_dev;
}
+/// Return the canonicalized absolute pathname.
+///
+/// @param[in] name Filename to be canonicalized.
+/// @param[out] buf Buffer to store the canonicalized values. A minimum length
+// of MAXPATHL+1 is required. If it is NULL, memory is
+// allocated. In that case, the caller should deallocate this
+// buffer.
+///
+/// @return pointer to the buf on success, or NULL.
+char *os_realpath(const char *name, char *buf)
+ FUNC_ATTR_NONNULL_ARG(1)
+{
+ uv_fs_t request;
+ int result = uv_fs_realpath(&fs_loop, &request, name, NULL);
+ if (result == kLibuvSuccess) {
+ if (buf == NULL) {
+ buf = xmallocz(MAXPATHL);
+ }
+ xstrlcpy(buf, request.ptr, MAXPATHL + 1);
+ }
+ uv_fs_req_cleanup(&request);
+ return result == kLibuvSuccess ? buf : NULL;
+}
+
#ifdef WIN32
# include <shlobj.h>