winsdk: Move file copying into NSIS installer

Change-Id: If01c5024af802be784d5ea0f897cebdcc604934d
diff --git a/windowsRuntimeInstaller/InstallerRT.nsi b/windowsRuntimeInstaller/InstallerRT.nsi
index 5bc2098..fd05914 100644
--- a/windowsRuntimeInstaller/InstallerRT.nsi
+++ b/windowsRuntimeInstaller/InstallerRT.nsi
@@ -216,6 +216,82 @@
 
 FunctionEnd
 
+; Initialize Explode variables
+Var /GLOBAL explString
+Var /GLOBAL explSeparator
+Var /GLOBAL explStrLen
+Var /GLOBAL explSepLen
+Var /GLOBAL explOffset
+Var /GLOBAL explTmp
+Var /GLOBAL explTmp2
+Var /GLOBAL explTmp3
+Var /GLOBAL explArrCount
+
+!macro Func_Explode un
+Function ${un}Explode
+  ; Get input from user
+  Pop $explString
+  Pop $explSeparator
+
+  ; Calculates initial values
+  StrLen $explStrLen $explString
+  StrLen $explSepLen $explSeparator
+  StrCpy $explArrCount 1
+
+  ${If}   $explStrLen <= 1          ;   If we got a single character
+  ${OrIf} $explSepLen > $explStrLen ;   or separator is larger than the string,
+    Push    $explString             ;   then we return initial string with no change
+    Push    1                       ;   and set array's length to 1
+    Return
+  ${EndIf}
+
+  ; Set offset to the last symbol of the string
+  StrCpy $explOffset $explStrLen
+  IntOp  $explOffset $explOffset - 1
+
+  ; Clear temp string to exclude the possibility of appearance of occasional data
+  StrCpy $explTmp   ""
+  StrCpy $explTmp2  ""
+  StrCpy $explTmp3  ""
+
+  ; Loop until the offset becomes negative
+  ${Do}
+    ;   If offset becomes negative, it is time to leave the function
+    ${IfThen} $explOffset == -1 ${|} ${ExitDo} ${|}
+
+    ;   Remove everything before and after the searched part ("TempStr")
+    StrCpy $explTmp $explString $explSepLen $explOffset
+
+    ${If} $explTmp == $explSeparator
+        ;   Calculating offset to start copy from
+        IntOp   $explTmp2 $explOffset + $explSepLen ;   Offset equals to the current offset plus length of separator
+        StrCpy  $explTmp3 $explString "" $explTmp2
+
+        Push    $explTmp3                           ;   Throwing array item to the stack
+        IntOp   $explArrCount $explArrCount + 1     ;   Increasing array's counter
+
+        StrCpy  $explString $explString $explOffset 0   ;   Cutting all characters beginning with the separator entry
+        StrLen  $explStrLen $explString
+    ${EndIf}
+
+    ${If} $explOffset = 0                       ;   If the beginning of the line met and there is no separator,
+                                                ;   copying the rest of the string
+        ${If} $explSeparator == ""              ;   Fix for the empty separator
+            IntOp   $explArrCount   $explArrCount - 1
+        ${Else}
+            Push    $explString
+        ${EndIf}
+    ${EndIf}
+
+    IntOp   $explOffset $explOffset - 1
+  ${Loop}
+
+  Push $explArrCount
+FunctionEnd
+!macroend
+!insertmacro Func_Explode ""
+!insertmacro Func_Explode "un."
+
 AddBrandingImage left 150
 Caption "${PRODUCTNAME} ${PRODUCTVERSION} Setup"
 Name "${PRODUCTNAME} ${PRODUCTVERSION}"
@@ -255,6 +331,27 @@
     Rename "configure_rt.log" "$TEMP\VulkanRT\configure_rt.log"
     pop $0
 
+    ${IF} $0 == 0
+        Pop $1
+        LogText "Output from ConfigureRT: $1"
+        Push ";"
+        Push "$1"
+        Call ${un}Explode
+        Pop $2
+        ${For} $4 1 $2
+            Pop $3
+            Push ">"
+            Push "$3"
+            Call ${un}Explode
+            Pop $5
+            ${IF} "$5" == "2"
+                Pop $6
+                Pop $7
+                CopyFiles /SILENT "$6" "$7"
+            ${ENDIF}
+        ${Next}
+    ${ENDIF}
+
     # Ignore errors. If something went wrong, the return value will indicate it.
     ClearErrors
 
diff --git a/windowsRuntimeInstaller/configure_runtime.c b/windowsRuntimeInstaller/configure_runtime.c
index df24a6f..ebf6774 100644
--- a/windowsRuntimeInstaller/configure_runtime.c
+++ b/windowsRuntimeInstaller/configure_runtime.c
@@ -697,20 +697,7 @@
         snprintf(output_filename, out_size, outPattern, path, name, extension);
     }
     
-    // Remove any older version of the output file
-    if(remove(output_filename) == 0) {
-        fprintf(log, "Removed file %s\n", output_filename);
-    } else {
-        fprintf(log, "Did not remove file %s\n", output_filename);
-    }
-    
-    fprintf(log, "Attempting to copy file %s to %s\n", latest_filename, output_filename);
-    if(CopyFile(latest_filename, output_filename, false) == 0) {
-        free(latest_filename);
-        free(output_filename);
-        return 215;
-    }
-    
+    fprintf(stdout, "%s>%s;", latest_filename, output_filename);
     free(latest_filename);
     free(output_filename);
     return 0;