@@ -75,23 +75,27 @@ Public Class Compactor
7575 End Function
7676
7777
78- Sub WOFCompressFile(path As String )
78+ Function WOFCompressFile(path As String )
7979
8080 Dim length As ULong = Marshal.SizeOf(_EFInfoPtr)
8181
8282 Using fs As FileStream = New FileStream(path, FileMode.Open)
8383 Dim hFile = fs.SafeFileHandle.DangerousGetHandle()
8484 Dim res = WofSetFileDataLocation(hFile, WOF_PROVIDER_FILE, _EFInfoPtr, length)
85- If res <> 0 Then
86- If res <> - 2147024552 Then
87- Debug.WriteLine( "spaghetti" )
88- End If
89-
90- End If
85+ Return res
9186 End Using
9287
93- End Sub
88+ End Function
89+
90+ Shared Function WOFDecompressFile(path As String )
9491
92+ Using fs As FileStream = New FileStream(path, FileMode.Open)
93+ Dim hDevice = fs.SafeFileHandle.DangerousGetHandle
94+ Dim res = DeviceIoControl(hDevice, FSCTL_DELETE_EXTERNAL_BACKING, IntPtr.Zero, 0 , IntPtr.Zero, 0 , IntPtr.Zero, IntPtr.Zero)
95+ Return res
96+ End Using
97+
98+ End Function
9599
96100 <Time>
97101 Async Function RunCompactAsync(progress As IProgress( Of (percentageProgress As Integer , currentFile As String ))) As Task( Of Boolean )
@@ -104,7 +108,7 @@ Public Class Compactor
104108
105109 Await Parallel.ForEachAsync(_filesList,
106110 Function (file, _ctx)
107- WOFCompressFile(file)
111+ Dim res = WOFCompressFile(file)
108112 'GenerateThread(_workingDir, compactArgs & " " & """" & file & """")
109113 Dim result = Interlocked.Increment(count)
110114 progress.Report(( CInt (((result / totalFiles) * 100 )), file))
@@ -164,7 +168,8 @@ Public Class Compactor
164168 Dim count As Integer = 0
165169 Await Parallel.ForEachAsync(filesList,
166170 Function (file, _ctx)
167- GenerateThread(workingDir, compactArgs & " " & """" & file & """" )
171+ Dim res = WOFDecompressFile(file)
172+ 'GenerateThread(workingDir, compactArgs & " " & """" & file & """")
168173 Dim result = Interlocked.Increment(count)
169174 progress.Report(( CInt (((result / totalFiles) * 100 )), file))
170175 End Function ).ConfigureAwait( False )
0 commit comments