lsteamclient: Move unix to dos path conversions to the unix side.

CW-Bug-Id: #22729
This commit is contained in:
Rémi Bernon
2023-10-02 23:28:09 +02:00
committed by Arkadiusz Hiler
parent 43481a24ff
commit c95536019c
45 changed files with 114 additions and 133 deletions

View File

@ -44,76 +44,6 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
return TRUE;
}
/* Returns:
* - if successful, the number of bytes written to dst, including the NULL terminator;
* - 0 if failed;
* - PATH_MAX if insufficient output buffer (TODO: should be actual required length including NULL terminator). */
unsigned int steamclient_unix_path_to_dos_path( bool api_result, const char *src, char *dst, uint32_t dst_bytes, int is_url )
{
static const char file_prot[] = "file://";
WCHAR *dosW;
uint32_t r;
if (!api_result)
{
if (dst && dst_bytes)
*dst = 0;
return 0;
}
if (!dst || !dst_bytes)
return PATH_MAX;
if (!src || !*src)
{
*dst = 0;
return PATH_MAX;
}
if (is_url)
{
/* convert only file: URLs */
if (strncmp(src, file_prot, 7))
{
r = strlen(src) + 1;
if (r > dst_bytes)
*dst = 0;
else
memmove(dst, src, r);
return r;
}
if (dst_bytes < sizeof(file_prot))
{
*dst = 0;
return PATH_MAX;
}
memmove(dst, src, 7);
src += 7;
dst += 7;
dst_bytes -= 7;
}
dosW = wine_get_dos_file_name(src);
if (!dosW)
{
WARN("Unable to convert unix filename to DOS: %s.\n", src);
*dst = 0;
return 0;
}
r = WideCharToMultiByte(CP_ACP, 0, dosW, -1, dst, dst_bytes,
NULL, NULL);
if (!r)
{
*dst = 0;
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
r = PATH_MAX;
}
HeapFree(GetProcessHeap(), 0, dosW);
return r;
}
static BYTE *alloc_start, *alloc_end;
static bool allocated_from_steamclient_dll( void *ptr )