mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 18:06:30 +00:00
Change resolve() to resolve symbolic links on Windows
This commit is contained in:
@@ -6709,7 +6709,10 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
const char *fname = tv_get_string(&argvars[0]);
|
const char *fname = tv_get_string(&argvars[0]);
|
||||||
#ifdef WIN32
|
#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);
|
rettv->vval.v_string = (char_u *)(v == NULL ? xstrdup(fname) : v);
|
||||||
#else
|
#else
|
||||||
# ifdef HAVE_READLINK
|
# ifdef HAVE_READLINK
|
||||||
|
@@ -1147,6 +1147,30 @@ bool os_fileid_equal_fileinfo(const FileID *file_id,
|
|||||||
&& file_id->device_id == file_info->stat.st_dev;
|
&& 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
|
#ifdef WIN32
|
||||||
# include <shlobj.h>
|
# include <shlobj.h>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user