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 @@ -20,6 +20,14 @@ Public Module SharedMethods
2020 Function GetFileSizeOnDisk(file As String ) As Long
2121 Dim hosize As UInteger
2222 Dim losize As UInteger = GetCompressedFileSizeW(file, hosize)
23+ 'INVALID_FILE_SIZE (0xFFFFFFFF)
24+ If losize = 4294967295 Then
25+ Dim errCode As Integer
26+ errCode = Marshal.GetLastPInvokeError()
27+ If errCode <> 0 Then
28+ Return - 1
29+ End If
30+ End If
2331 Return CLng (hosize) << 32 Or losize
2432 End Function
2533
@@ -72,7 +80,7 @@ Public Module SharedMethods
7280
7381# Region "DLL Imports"
7482
75- <DllImport( "kernel32.dll" )>
83+ <DllImport( "kernel32.dll" , SetLastError:= True )>
7684 Private Function GetCompressedFileSizeW(
7785 <[In](), MarshalAs(UnmanagedType.LPWStr)> lpFileName As String ,
7886 < Out (), MarshalAs(UnmanagedType.U4)> ByRef lpFileSizeHigh As UInteger) _
You can’t perform that action at this time.
0 commit comments