mirror of
https://github.com/reactos/ccache.git
synced 2024-11-23 11:49:41 +00:00
Implement x_realpath for Windows
This commit is contained in:
parent
e11912151c
commit
79c048c00e
15
util.c
15
util.c
@ -81,7 +81,6 @@ log_prefix(bool log_updated_time)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
static long
|
static long
|
||||||
path_max(const char *path)
|
path_max(const char *path)
|
||||||
{
|
{
|
||||||
@ -100,7 +99,6 @@ path_max(const char *path)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* !_WIN32 */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vlog(const char *format, va_list ap, bool log_updated_time)
|
vlog(const char *format, va_list ap, bool log_updated_time)
|
||||||
@ -938,7 +936,7 @@ parse_size_with_suffix(const char *str, uint64_t *size)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
/*
|
/*
|
||||||
a sane realpath() function, trying to cope with stupid path limits and
|
a sane realpath() function, trying to cope with stupid path limits and
|
||||||
a broken API
|
a broken API
|
||||||
@ -948,11 +946,21 @@ x_realpath(const char *path)
|
|||||||
{
|
{
|
||||||
long maxlen = path_max(path);
|
long maxlen = path_max(path);
|
||||||
char *ret, *p;
|
char *ret, *p;
|
||||||
|
#ifdef _WIN32
|
||||||
|
HANDLE path_handle;
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = x_malloc(maxlen);
|
ret = x_malloc(maxlen);
|
||||||
|
|
||||||
#if HAVE_REALPATH
|
#if HAVE_REALPATH
|
||||||
p = realpath(path, ret);
|
p = realpath(path, ret);
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
path_handle = CreateFile(
|
||||||
|
path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
||||||
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
GetFinalPathNameByHandle(path_handle, ret, maxlen, FILE_NAME_NORMALIZED);
|
||||||
|
CloseHandle(path_handle);
|
||||||
|
p = ret+4;// strip the \\?\ from the file name
|
||||||
#else
|
#else
|
||||||
/* yes, there are such systems. This replacement relies on
|
/* yes, there are such systems. This replacement relies on
|
||||||
the fact that when we call x_realpath we only care about symlinks */
|
the fact that when we call x_realpath we only care about symlinks */
|
||||||
@ -974,7 +982,6 @@ x_realpath(const char *path)
|
|||||||
free(ret);
|
free(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif /* !_WIN32 */
|
|
||||||
|
|
||||||
/* a getcwd that will returns an allocated buffer */
|
/* a getcwd that will returns an allocated buffer */
|
||||||
char *
|
char *
|
||||||
|
Loading…
Reference in New Issue
Block a user