Commit aa4fe067 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

setupapi: Implement SetupGetFileCompressionInfo on top of SetupGetFileCompressionInfoEx.

parent 2423c9f0
......@@ -1201,6 +1201,81 @@ BOOL WINAPI SetupGetFileCompressionInfoExW( PCWSTR source, PWSTR name, DWORD len
return ret;
}
/***********************************************************************
* SetupGetFileCompressionInfoA (SETUPAPI.@)
*
* See SetupGetFileCompressionInfoW.
*/
DWORD WINAPI SetupGetFileCompressionInfoA( PCSTR source, PSTR *name, PDWORD source_size,
PDWORD target_size, PUINT type )
{
BOOL ret;
DWORD error, required;
LPSTR actual_name;
TRACE("%s, %p, %p, %p, %p\n", debugstr_a(source), name, source_size, target_size, type);
if (!source || !name || !source_size || !target_size || !type)
return ERROR_INVALID_PARAMETER;
ret = SetupGetFileCompressionInfoExA( source, NULL, 0, &required, NULL, NULL, NULL );
if (!(actual_name = MyMalloc( required ))) return ERROR_NOT_ENOUGH_MEMORY;
ret = SetupGetFileCompressionInfoExA( source, actual_name, required, &required,
source_size, target_size, type );
if (!ret)
{
error = GetLastError();
MyFree( actual_name );
return error;
}
*name = actual_name;
return ERROR_SUCCESS;
}
/***********************************************************************
* SetupGetFileCompressionInfoW (SETUPAPI.@)
*
* Get compression type and compressed/uncompressed sizes of a given file.
*
* PARAMS
* source [I] File to examine.
* name [O] Actual filename used.
* source_size [O] Size of compressed file.
* target_size [O] Size of uncompressed file.
* type [O] Compression type.
*
* RETURNS
* Success: ERROR_SUCCESS
* Failure: Win32 error code.
*/
DWORD WINAPI SetupGetFileCompressionInfoW( PCWSTR source, PWSTR *name, PDWORD source_size,
PDWORD target_size, PUINT type )
{
BOOL ret;
DWORD error, required;
LPWSTR actual_name;
TRACE("%s, %p, %p, %p, %p\n", debugstr_w(source), name, source_size, target_size, type);
if (!source || !name || !source_size || !target_size || !type)
return ERROR_INVALID_PARAMETER;
ret = SetupGetFileCompressionInfoExW( source, NULL, 0, &required, NULL, NULL, NULL );
if (!(actual_name = MyMalloc( required ))) return ERROR_NOT_ENOUGH_MEMORY;
ret = SetupGetFileCompressionInfoExW( source, actual_name, required, &required,
source_size, target_size, type );
if (!ret)
{
error = GetLastError();
MyFree( actual_name );
return error;
}
*name = actual_name;
return ERROR_SUCCESS;
}
static DWORD decompress_file_lz( LPCWSTR source, LPCWSTR target )
{
DWORD ret;
......
......@@ -395,10 +395,10 @@
@ stub SetupGetBackupInformationW
@ stdcall SetupGetBinaryField(ptr long ptr long ptr)
@ stdcall SetupGetFieldCount(ptr)
@ stub SetupGetFileCompressionInfoA
@ stdcall SetupGetFileCompressionInfoA(str ptr ptr ptr ptr)
@ stdcall SetupGetFileCompressionInfoExA(str ptr long ptr ptr ptr ptr)
@ stdcall SetupGetFileCompressionInfoExW(wstr ptr long ptr ptr ptr ptr)
@ stub SetupGetFileCompressionInfoW
@ stdcall SetupGetFileCompressionInfoW(wstr ptr ptr ptr ptr)
@ stdcall SetupGetFileQueueCount(long long ptr)
@ stdcall SetupGetFileQueueFlags(long ptr)
@ stub SetupGetInfFileListA
......
......@@ -316,6 +316,46 @@ static const BYTE comp_cab_zip[] = {
0x2d, 0x28, 0x4a, 0x2d, 0x2e, 0x4e, 0x4d, 0xe1, 0xe5, 0x02, 0x00
};
static void test_SetupGetFileCompressionInfo(void)
{
DWORD ret, source_size, target_size;
char source[MAX_PATH], temp[MAX_PATH], *name;
UINT type;
GetTempPathA(sizeof(temp), temp);
GetTempFileNameA(temp, "fci", 0, source);
create_source_file(source, uncompressed, sizeof(uncompressed));
ret = SetupGetFileCompressionInfoA(NULL, NULL, NULL, NULL, NULL);
ok(ret == ERROR_INVALID_PARAMETER, "SetupGetFileCompressionInfo failed unexpectedly\n");
ret = SetupGetFileCompressionInfoA(source, NULL, NULL, NULL, NULL);
ok(ret == ERROR_INVALID_PARAMETER, "SetupGetFileCompressionInfo failed unexpectedly\n");
ret = SetupGetFileCompressionInfoA(source, &name, NULL, NULL, NULL);
ok(ret == ERROR_INVALID_PARAMETER, "SetupGetFileCompressionInfo failed unexpectedly\n");
ret = SetupGetFileCompressionInfoA(source, &name, &source_size, NULL, NULL);
ok(ret == ERROR_INVALID_PARAMETER, "SetupGetFileCompressionInfo failed unexpectedly\n");
ret = SetupGetFileCompressionInfoA(source, &name, &source_size, &target_size, NULL);
ok(ret == ERROR_INVALID_PARAMETER, "SetupGetFileCompressionInfo failed unexpectedly\n");
name = NULL;
source_size = target_size = 0;
type = 5;
ret = SetupGetFileCompressionInfoA(source, &name, &source_size, &target_size, &type);
ok(!ret, "SetupGetFileCompressionInfo failed unexpectedly\n");
ok(name && !lstrcmpA(name, source), "got %s, expected %s\n", name, source);
ok(source_size == sizeof(uncompressed), "got %d\n", source_size);
ok(target_size == sizeof(uncompressed), "got %d\n", target_size);
ok(type == FILE_COMPRESSION_NONE, "got %d, expected FILE_COMPRESSION_NONE\n", type);
DeleteFileA(source);
}
static void test_SetupGetFileCompressionInfoEx(void)
{
BOOL ret;
......@@ -491,6 +531,7 @@ START_TEST(misc)
GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
test_SetupCopyOEMInf();
test_SetupGetFileCompressionInfo();
if (pSetupGetFileCompressionInfoExA)
test_SetupGetFileCompressionInfoEx();
......
......@@ -819,6 +819,9 @@ BOOL WINAPI SetupFindNextMatchLineW( PINFCONTEXT context_in, PCWSTR key, PIN
#define SetupFindNextMatchLine WINELIB_NAME_AW(SetupFindNextMatchLine)
BOOL WINAPI SetupGetBinaryField( PINFCONTEXT context, DWORD index, BYTE *buffer, DWORD size, LPDWORD required );
DWORD WINAPI SetupGetFieldCount( PINFCONTEXT context );
DWORD WINAPI SetupGetFileCompressionInfoA(PCSTR, PSTR *, PDWORD, PDWORD, PUINT);
DWORD WINAPI SetupGetFileCompressionInfoW(PCWSTR, PWSTR *, PDWORD, PDWORD, PUINT);
#define SetupGetFileCompressionInfo WINELIB_NAME_AW(SetupGetFileCompressionInfo)
BOOL WINAPI SetupGetFileCompressionInfoExA(PCSTR, PSTR, DWORD, PDWORD, PDWORD, PDWORD, PUINT);
BOOL WINAPI SetupGetFileCompressionInfoExW(PCWSTR, PWSTR, DWORD, PDWORD, PDWORD, PDWORD, PUINT);
#define SetupGetFileCompressionInfoEx WINELIB_NAME_AW(SetupGetFileCompressionInfoEx)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment