Skip to content

Commit bca03ae

Browse files
committed
Merge branch 'master' of https://github.com/IridiumIO/CompactGUI
2 parents 14de2d5 + 3aaf764 commit bca03ae

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CompactGUI.Core/Analyser.vb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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!

CompactGUI.Core/SharedMethods.vb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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) _

0 commit comments

Comments
 (0)