Hans Leidekker : setupapi: Implement SetupGetFileCompressionInfo on top of SetupGetFileCompressionInfoEx .

Alexandre Julliard julliard at wine.codeweavers.com
Tue Apr 10 14:58:08 CDT 2007


Module: wine
Branch: master
Commit: aa4fe0673987f4b5d065c6446973514b2f7cad73
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=aa4fe0673987f4b5d065c6446973514b2f7cad73

Author: Hans Leidekker <hans at it.vu.nl>
Date:   Tue Apr 10 20:22:39 2007 +0200

setupapi: Implement SetupGetFileCompressionInfo on top of SetupGetFileCompressionInfoEx.

---

 dlls/setupapi/misc.c        |   75 +++++++++++++++++++++++++++++++++++++++++++
 dlls/setupapi/setupapi.spec |    4 +-
 dlls/setupapi/tests/misc.c  |   41 +++++++++++++++++++++++
 include/setupapi.h          |    3 ++
 4 files changed, 121 insertions(+), 2 deletions(-)

diff --git a/dlls/setupapi/misc.c b/dlls/setupapi/misc.c
index e77bf87..a9e1e82 100644
--- a/dlls/setupapi/misc.c
+++ b/dlls/setupapi/misc.c
@@ -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;
diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec
index 1669cc4..b523644 100644
--- a/dlls/setupapi/setupapi.spec
+++ b/dlls/setupapi/setupapi.spec
@@ -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
diff --git a/dlls/setupapi/tests/misc.c b/dlls/setupapi/tests/misc.c
index cbfc647..9368540 100644
--- a/dlls/setupapi/tests/misc.c
+++ b/dlls/setupapi/tests/misc.c
@@ -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();
diff --git a/include/setupapi.h b/include/setupapi.h
index dd20435..837278c 100644
--- a/include/setupapi.h
+++ b/include/setupapi.h
@@ -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)




More information about the wine-cvs mailing list