vrclient: 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:53:50 +02:00 committed by Arkadiusz Hiler
parent c95536019c
commit 1e8d243065
7 changed files with 36 additions and 40 deletions

View File

@ -798,6 +798,14 @@ def handle_method_cpp(method, classname, out):
for name, param in sorted(need_output.items()):
out(f' if (params->{name}) *params->{name} = u_{name};\n')
path_conv_utow = PATH_CONV_METHODS_UTOW.get(f'{klass.name}_{method.spelling}', {})
for name, conv in filter(lambda x: x[0] in names, path_conv_utow.items()):
out(u' ')
if "ret_size" in path_conv_utow:
out(u'params->_ret = ')
out(f'vrclient_unix_path_to_dos_path( params->_ret, params->{name}, params->{name}, params->{conv["len"]} );\n')
for name in filter(lambda x: x in names, sorted(path_conv_wtou)):
out(f' vrclient_free_path( u_{name} );\n')
@ -851,8 +859,6 @@ def handle_method_c(klass, method, winclassname, out):
out(f' .{name} = {name},\n')
out(u' };\n')
path_conv_utow = PATH_CONV_METHODS_UTOW.get(f'{klass.name}_{method.spelling}', {})
out(u' TRACE("%p\\n", _this);\n')
if 'eTextureType' in names:
@ -860,12 +866,6 @@ def handle_method_c(klass, method, winclassname, out):
out(f' VRCLIENT_CALL( {method.full_name}, &params );\n')
for name, conv in filter(lambda x: x[0] in names, path_conv_utow.items()):
out(u' ')
if "ret_size" in path_conv_utow:
out(u'params._ret = ')
out(f'vrclient_unix_path_to_dos_path( params._ret, {name}, {name}, {conv["len"]} );\n')
if not returns_void:
out(u' return params._ret;\n')
out(u'}\n\n')

View File

@ -34,6 +34,7 @@ NTSTATUS IVRScreenshots_IVRScreenshots_001_GetScreenshotPropertyFilename( void *
struct IVRScreenshots_IVRScreenshots_001_GetScreenshotPropertyFilename_params *params = (struct IVRScreenshots_IVRScreenshots_001_GetScreenshotPropertyFilename_params *)args;
struct u_IVRScreenshots_IVRScreenshots_001 *iface = (struct u_IVRScreenshots_IVRScreenshots_001 *)params->linux_side;
params->_ret = (uint32_t)iface->GetScreenshotPropertyFilename( params->screenshotHandle, params->filenameType, params->pchFilename, params->cchFilename, params->pError );
params->_ret = vrclient_unix_path_to_dos_path( params->_ret, params->pchFilename, params->pchFilename, params->cchFilename );
return 0;
}

View File

@ -80,6 +80,32 @@ void vrclient_free_path( char *path )
HeapFree( GetProcessHeap(), 0, path );
}
/* returns the number of bytes written to dst, not including the NUL terminator */
unsigned int vrclient_unix_path_to_dos_path( bool api_result, const char *src, char *dst, uint32_t dst_bytes )
{
WCHAR *dosW;
uint32_t r;
if (!src || !*src || !api_result || !dst || !dst_bytes)
{
if (dst && dst_bytes) *dst = 0;
return 0;
}
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 );
HeapFree( GetProcessHeap(), 0, dosW );
return r == 0 ? 0 : r - 1;
}
extern "C" {
static bool ends_with(const std::string &s, char c)

View File

@ -31,6 +31,7 @@ extern NTSTATUS vrclient_VRClientCoreFactory( void *args );
extern char *vrclient_dos_to_unix_path( const char *src );
extern void vrclient_free_path( char *path );
extern unsigned int vrclient_unix_path_to_dos_path( bool api_result, const char *src, char *dst, uint32_t dst_bytes );
#ifdef __cplusplus
} /* extern "C" */

View File

@ -57,36 +57,6 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
return TRUE;
}
/* returns the number of bytes written to dst, not including the NUL terminator */
unsigned int vrclient_unix_path_to_dos_path(bool api_result, const char *src, char *dst, uint32_t dst_bytes)
{
WCHAR *dosW;
uint32_t r;
if(!dst || !dst_bytes)
return 0;
if(!src || !api_result){
*dst = 0;
return 0;
}
dosW = wine_get_dos_file_name(src);
*dst = 0;
if(!dosW){
WARN("Unable to convert unix filename to DOS: %s\n", src);
return 0;
}
r = WideCharToMultiByte(CP_ACP, 0, dosW, -1, dst, dst_bytes,
NULL, NULL);
HeapFree(GetProcessHeap(), 0, dosW);
return r == 0 ? 0 : r - 1;
}
static BOOL array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
{
SIZE_T max_capacity, new_capacity;

View File

@ -12,7 +12,6 @@
typedef void (*vtable_ptr)(void);
#endif
unsigned int vrclient_unix_path_to_dos_path(bool api_result, const char *src, char *dst, uint32_t dst_bytes);
void *create_LinuxMatchmakingServerListResponse(void *win);
#ifndef __cplusplus

View File

@ -70,7 +70,6 @@ uint32_t __thiscall winIVRScreenshots_IVRScreenshots_001_GetScreenshotPropertyFi
};
TRACE("%p\n", _this);
VRCLIENT_CALL( IVRScreenshots_IVRScreenshots_001_GetScreenshotPropertyFilename, &params );
params._ret = vrclient_unix_path_to_dos_path( params._ret, pchFilename, pchFilename, cchFilename );
return params._ret;
}