[SETUPAPI]
[reactos.git] / reactos / dll / win32 / setupapi / queue.c
index 571ad3b..6848868 100644 (file)
@@ -22,8 +22,6 @@
 
 #include <aclapi.h>
 
-WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
-
 /* Unicode constants */
 static const WCHAR DotSecurity[]     = {'.','S','e','c','u','r','i','t','y',0};
 
@@ -461,6 +459,7 @@ BOOL WINAPI SetupQueueCopyIndirectA( PSP_FILE_COPY_PARAMS_A params )
     op->src_tag    = strdupAtoW( params->SourceTagfile );
     op->dst_path   = strdupAtoW( params->TargetDirectory );
     op->dst_file   = strdupAtoW( params->TargetFilename );
+    op->dst_sd     = NULL;
 
     /* some defaults */
     if (!op->src_file) op->src_file = op->dst_file;
@@ -634,6 +633,7 @@ BOOL WINAPI SetupQueueDeleteA( HSPFILEQ handle, PCSTR part1, PCSTR part2 )
     op->src_tag    = NULL;
     op->dst_path   = strdupAtoW( part1 );
     op->dst_file   = strdupAtoW( part2 );
+    op->dst_sd     = NULL;
     queue_file_op( &queue->delete_queue, op );
     return TRUE;
 }
@@ -656,6 +656,7 @@ BOOL WINAPI SetupQueueDeleteW( HSPFILEQ handle, PCWSTR part1, PCWSTR part2 )
     op->src_tag    = NULL;
     op->dst_path   = strdupW( part1 );
     op->dst_file   = strdupW( part2 );
+    op->dst_sd     = NULL;
     queue_file_op( &queue->delete_queue, op );
     return TRUE;
 }
@@ -679,6 +680,7 @@ BOOL WINAPI SetupQueueRenameA( HSPFILEQ handle, PCSTR SourcePath, PCSTR SourceFi
     op->src_tag    = NULL;
     op->dst_path   = strdupAtoW( TargetPath );
     op->dst_file   = strdupAtoW( TargetFilename );
+    op->dst_sd     = NULL;
     queue_file_op( &queue->rename_queue, op );
     return TRUE;
 }
@@ -702,6 +704,7 @@ BOOL WINAPI SetupQueueRenameW( HSPFILEQ handle, PCWSTR SourcePath, PCWSTR Source
     op->src_tag    = NULL;
     op->dst_path   = strdupW( TargetPath );
     op->dst_file   = strdupW( TargetFilename );
+    op->dst_sd     = NULL;
     queue_file_op( &queue->rename_queue, op );
     return TRUE;
 }
@@ -986,9 +989,27 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
 {
     BOOL rc = FALSE;
     BOOL docopy = TRUE;
+    WCHAR TempFile[MAX_PATH];
+    INT hSource, hTemp;
+    OFSTRUCT OfStruct;
+    WCHAR TempPath[MAX_PATH];
 
     TRACE("copy %s to %s style 0x%x\n",debugstr_w(source),debugstr_w(target),style);
 
+    hSource = LZOpenFileW((LPWSTR)source, &OfStruct, OF_READ);
+    if (hSource < 0)
+        return FALSE;
+
+    /* Get a temp file name */
+    GetTempPathW(sizeof(TempPath) / sizeof(WCHAR), TempPath);
+    GetTempFileNameW(TempPath, L"", 0, TempFile);
+
+    /* Extract the compressed file to a temp location */
+    hTemp = LZOpenFileW(TempFile, &OfStruct, OF_CREATE);
+    LZCopy(hSource, hTemp);
+    LZClose(hSource);
+    LZClose(hTemp);
+
     /* before copy processing */
     if (style & SP_COPY_REPLACEONLY)
     {
@@ -1012,9 +1033,9 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
          * we just basically unconditionally replace the builtin versions.
          */
         if ((GetFileAttributesW(target) != INVALID_FILE_ATTRIBUTES) &&
-            (GetFileAttributesW(source) != INVALID_FILE_ATTRIBUTES))
+            (GetFileAttributesW(TempFile) != INVALID_FILE_ATTRIBUTES))
         {
-            VersionSizeSource = GetFileVersionInfoSizeW((LPWSTR)source,&zero);
+            VersionSizeSource = GetFileVersionInfoSizeW(TempFile,&zero);
             VersionSizeTarget = GetFileVersionInfoSizeW((LPWSTR)target,&zero);
         }
 
@@ -1034,7 +1055,7 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
             VersionSource = HeapAlloc(GetProcessHeap(),0,VersionSizeSource);
             VersionTarget = HeapAlloc(GetProcessHeap(),0,VersionSizeTarget);
 
-            ret = GetFileVersionInfoW((LPWSTR)source,0,VersionSizeSource,VersionSource);
+            ret = GetFileVersionInfoW(TempFile,0,VersionSizeSource,VersionSource);
             if (ret)
               ret = GetFileVersionInfoW((LPWSTR)target, 0, VersionSizeTarget,
                     VersionTarget);
@@ -1109,7 +1130,7 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
 
     if (docopy)
     {
-        rc = CopyFileW(source,target,FALSE);
+        rc = MoveFileExW(TempFile,target,MOVEFILE_REPLACE_EXISTING);
         TRACE("Did copy... rc was %i\n",rc);
     }
 
@@ -1195,7 +1216,11 @@ BOOL WINAPI SetupInstallFileW( HINF hinf, PINFCONTEXT inf_context, PCWSTR source
             SetLastError( ERROR_NOT_ENOUGH_MEMORY );
             return FALSE;
         }
-        if (!SetupGetStringFieldW( inf_context, 1, inf_source, len, NULL )) return FALSE;
+        if (!SetupGetStringFieldW( inf_context, 1, inf_source, len, NULL ))
+        {
+            HeapFree( GetProcessHeap(), 0, inf_source );
+            return FALSE;
+        }
         source = inf_source;
     }
     else if (!source)