[1/7] msi: Factor out common code from MsiEnumComponentCostsW.

Hans Leidekker hans at codeweavers.com
Fri May 20 05:32:23 CDT 2011


---
 dlls/msi/msi.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 0f11024..5075756 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -1825,6 +1825,14 @@ UINT WINAPI MsiEnumComponentCostsA( MSIHANDLE handle, LPCSTR component, DWORD in
     return r;
 }
 
+static UINT set_drive( WCHAR *buffer, WCHAR letter )
+{
+    buffer[0] = letter;
+    buffer[1] = ':';
+    buffer[2] = 0;
+    return 2;
+}
+
 UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD index,
                                     INSTALLSTATE state, LPWSTR drive, DWORD *buflen,
                                     int *cost, int *temp )
@@ -1896,29 +1904,20 @@ UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD i
         if (!comp->Enabled || !comp->KeyPath)
         {
             *cost = 0;
-            drive[0] = path[0];
-            drive[1] = ':';
-            drive[2] = 0;
-            *buflen = 2;
+            *buflen = set_drive( drive, path[0] );
             r = ERROR_SUCCESS;
         }
         else if ((file = msi_get_loaded_file( package, comp->KeyPath )))
         {
             *cost = max( 8, comp->Cost / 512 );
-            drive[0] = file->TargetPath[0];
-            drive[1] = ':';
-            drive[2] = 0;
-            *buflen = 2;
+            *buflen = set_drive( drive, file->TargetPath[0] );
             r = ERROR_SUCCESS;
         }
     }
     else if (IStorage_Stat( package->db->storage, &stat, STATFLAG_NONAME ) == S_OK)
     {
         *temp = max( 8, stat.cbSize.QuadPart / 512 );
-        drive[0] = path[0];
-        drive[1] = ':';
-        drive[2] = 0;
-        *buflen = 2;
+        *buflen = set_drive( drive, path[0] );
         r = ERROR_SUCCESS;
     }
     msiobj_release( &package->hdr );
-- 
1.7.4.1







More information about the wine-patches mailing list