File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,10 @@ Public Class Analyser
3939 Dim fInfo As New FileInfo(file)
4040 Dim unCompSize = fInfo.Length
4141 Dim compSize = GetFileSizeOnDisk(file)
42+ If compSize < 0 Then
43+ 'GetFileSizeOnDisk failed, fall back to unCompSize
44+ compSize = unCompSize
45+ End If
4246 Dim cLevel As CompressionAlgorithm = If (compSize = unCompSize, CompressionAlgorithm.NO_COMPRESSION, DetectCompression(fInfo))
4347
4448 'Sets the backing private fields directly because Interlocked doesn't play nice with properties!
Original file line number Diff line number Diff line change @@ -21,6 +21,14 @@ Public Module SharedMethods
2121 Function GetFileSizeOnDisk(file As String ) As Long
2222 Dim hosize As UInteger
2323 Dim losize As UInteger = GetCompressedFileSizeW(file, hosize)
24+ 'INVALID_FILE_SIZE (0xFFFFFFFF)
25+ If losize = 4294967295 Then
26+ Dim errCode As Integer
27+ errCode = Marshal.GetLastPInvokeError()
28+ If errCode <> 0 Then
29+ Return - 1
30+ End If
31+ End If
2432 Return CLng (hosize) << 32 Or losize
2533 End Function
2634
@@ -73,7 +81,7 @@ Public Module SharedMethods
7381
7482# Region "DLL Imports"
7583
76- <DllImport( "kernel32.dll" )>
84+ <DllImport( "kernel32.dll" , SetLastError:= True )>
7785 Private Function GetCompressedFileSizeW(
7886 <[In](), MarshalAs(UnmanagedType.LPWStr)> lpFileName As String ,
7987 < Out (), MarshalAs(UnmanagedType.U4)> ByRef lpFileSizeHigh As UInteger) _
You can’t perform that action at this time.
0 commit comments