mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 00:13:01 -05:00
tst: passthrough-fuse: fix UNC path mount
This commit is contained in:
parent
760c2acded
commit
c06141c8c8
@ -461,7 +461,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
char buf[PATH_MAX * 4];
|
||||
if (-1 != getpath(ptfs.rootdir, buf, sizeof buf))
|
||||
{
|
||||
ptfs.rootlen = strlen(buf);
|
||||
|
@ -131,21 +131,44 @@ char *realpath(const char *path, char *resolved)
|
||||
int err = 0;
|
||||
WCHAR PathBuf[PATH_MAX];
|
||||
WCHAR ResultBuf[PATH_MAX];
|
||||
PWSTR ResultBufBgn = &ResultBuf[6];
|
||||
if (0 < MultiByteToWideChar(CP_UTF8, 0, path, -1, PathBuf, PATH_MAX))
|
||||
{
|
||||
DWORD len = GetFullPathNameW(PathBuf, PATH_MAX, ResultBuf, 0);
|
||||
DWORD len = GetFullPathNameW(PathBuf, PATH_MAX - 6, ResultBufBgn, 0);
|
||||
if (0 == len)
|
||||
err = GetLastError();
|
||||
else if (PATH_MAX < len)
|
||||
else if (PATH_MAX - 6 < len)
|
||||
err = ERROR_INVALID_PARAMETER;
|
||||
WideCharToMultiByte(CP_UTF8, 0, ResultBuf, -1, result, PATH_MAX * 4, 0, 0);
|
||||
else
|
||||
{
|
||||
WideCharToMultiByte(CP_UTF8, 0, ResultBufBgn, -1, result, PATH_MAX * 4, 0, 0);
|
||||
if (L'\\' == ResultBufBgn[0] && L'\\' == ResultBufBgn[1])
|
||||
{
|
||||
ResultBufBgn = ResultBuf;
|
||||
ResultBufBgn[0] = L'\\';
|
||||
ResultBufBgn[1] = L'\\';
|
||||
ResultBufBgn[2] = L'?';
|
||||
ResultBufBgn[3] = L'\\';
|
||||
ResultBufBgn[4] = L'U';
|
||||
ResultBufBgn[5] = L'N';
|
||||
ResultBufBgn[6] = L'C';
|
||||
}
|
||||
else
|
||||
{
|
||||
ResultBufBgn = &ResultBuf[2];
|
||||
ResultBufBgn[0] = L'\\';
|
||||
ResultBufBgn[1] = L'\\';
|
||||
ResultBufBgn[2] = L'?';
|
||||
ResultBufBgn[3] = L'\\';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
err = GetLastError();
|
||||
|
||||
if (0 == err)
|
||||
{
|
||||
HANDLE h = CreateFileW(ResultBuf,
|
||||
HANDLE h = CreateFileW(ResultBufBgn,
|
||||
FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||
0,
|
||||
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
|
||||
@ -163,25 +186,48 @@ char *realpath(const char *path, char *resolved)
|
||||
errno = maperror(err);
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int uncpath(const char *path, WCHAR *buf, int nchar)
|
||||
{
|
||||
if (4 < nchar &&
|
||||
0 < MultiByteToWideChar(CP_UTF8, 0, path, -1, &buf[4], nchar - 4))
|
||||
PWSTR BufP = 0;
|
||||
if ('\\' == path[0] && '\\' == path[1])
|
||||
{
|
||||
buf[0] = L'\\';
|
||||
buf[1] = L'\\';
|
||||
buf[2] = L'?';
|
||||
buf[3] = L'\\';
|
||||
int i = 4;
|
||||
while (buf[i])
|
||||
if (8 < nchar &&
|
||||
0 < MultiByteToWideChar(CP_UTF8, 0, &path[2], -1, &buf[8], nchar - 8))
|
||||
{
|
||||
if (L'/' == buf[i])
|
||||
buf[i] = L'\\';
|
||||
i++;
|
||||
BufP = &buf[8];
|
||||
buf[0] = L'\\';
|
||||
buf[1] = L'\\';
|
||||
buf[2] = L'?';
|
||||
buf[3] = L'\\';
|
||||
buf[4] = L'U';
|
||||
buf[5] = L'N';
|
||||
buf[6] = L'C';
|
||||
buf[7] = L'\\';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (4 < nchar &&
|
||||
0 < MultiByteToWideChar(CP_UTF8, 0, path, -1, &buf[4], nchar - 4))
|
||||
{
|
||||
BufP = &buf[4];
|
||||
buf[0] = L'\\';
|
||||
buf[1] = L'\\';
|
||||
buf[2] = L'?';
|
||||
buf[3] = L'\\';
|
||||
}
|
||||
}
|
||||
|
||||
if (BufP)
|
||||
{
|
||||
while (*BufP)
|
||||
{
|
||||
if (L'/' == *BufP)
|
||||
*BufP = L'\\';
|
||||
BufP++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user