Skip to content

Commit 3c15171

Browse files
committed
Improved Filters
Added Status Bar Bug Fixes
1 parent dbe4671 commit 3c15171

File tree

12 files changed

+661
-381
lines changed

12 files changed

+661
-381
lines changed

DiskImageTool/ComboFileType.vb

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
Public Enum FilterTypes
2+
UnknownOEMID = 1
3+
MismatchedOEMID = 2
4+
HasCreated = 4
5+
HasLastAccessed = 8
6+
HasInvalidImage = 16
7+
HasLongFileNames = 32
8+
HasInvalidDirectoryEntries = 64
9+
ModifiedFiles = 128
10+
End Enum
11+
12+
Public Class ComboFileType
13+
Private _ID As FilterTypes
14+
Private _Count As Integer
15+
16+
Public Property Count As Integer
17+
Get
18+
Return _Count
19+
End Get
20+
Set
21+
_Count = Value
22+
End Set
23+
End Property
24+
25+
Public Property ID As FilterTypes
26+
Get
27+
Return _ID
28+
End Get
29+
Set
30+
_ID = Value
31+
End Set
32+
End Property
33+
Public Sub New(ID As FilterTypes, Count As Integer)
34+
_ID = ID
35+
_Count = Count
36+
End Sub
37+
Public Overrides Function ToString() As String
38+
Return GetText() & " [" & Count & "]"
39+
End Function
40+
41+
Private Function GetText() As String
42+
Select Case ID
43+
Case FilterTypes.UnknownOEMID
44+
Return "Unknown OEM ID"
45+
Case FilterTypes.MismatchedOEMID
46+
Return "Mismatched OEM ID"
47+
Case FilterTypes.HasCreated
48+
Return "Has Creation Date"
49+
Case FilterTypes.HasLastAccessed
50+
Return "Has Last Access Date"
51+
Case FilterTypes.HasInvalidImage
52+
Return "Invalid Image"
53+
Case FilterTypes.HasLongFileNames
54+
Return "Has Long File Names"
55+
Case FilterTypes.HasInvalidDirectoryEntries
56+
Return "Has Invalid Directory Entries"
57+
Case FilterTypes.ModifiedFiles
58+
Return "Modified Files"
59+
Case Else
60+
Return ""
61+
End Select
62+
End Function
63+
End Class
64+
65+
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Public Class BootSector
33
Private Enum BootSectorOffset As UInteger
44
Code = 0
5-
OSName = 3
5+
OEMID = 3
66
BytesPerSector = 11
77
SectorsPerCluster = 13
88
ReservedSectors = 14
@@ -27,7 +27,7 @@
2727

2828
Private Enum BootSectorSize As UInteger
2929
Code = 3
30-
OSName = 8
30+
OEMID = 8
3131
VolumeLabel = 11
3232
FileSystemType = 8
3333
BootStrapCode = 448
@@ -188,12 +188,12 @@
188188
End Set
189189
End Property
190190

191-
Public Property OSName() As Byte()
191+
Public Property OEMID() As Byte()
192192
Get
193-
Return _Parent.GetBytes(BootSectorOffset.OSName, BootSectorSize.OSName)
193+
Return _Parent.GetBytes(BootSectorOffset.OEMID, BootSectorSize.OEMID)
194194
End Get
195195
Set
196-
_Parent.SetBytes(Value, BootSectorOffset.OSName, BootSectorSize.OSName, 0)
196+
_Parent.SetBytes(Value, BootSectorOffset.OEMID, BootSectorSize.OEMID, 0)
197197
End Set
198198
End Property
199199

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Namespace DiskImage
5959
LFNFilePart3 = 4
6060
End Enum
6161

62-
Private ReadOnly InvalidChars() As Byte = {&H22, &H2B, &H2C, &H2F, &H3A, &H3B, &H3C, &H3D, &H3E, &H3F, &H5B, &H5C, &H5D, &H7C}
62+
Private ReadOnly InvalidChars() As Byte = {&H22, &H2B, &H2C, &H2E, &H2F, &H3A, &H3B, &H3C, &H3D, &H3E, &H3F, &H5B, &H5C, &H5D, &H7C, &H7F}
6363
Private ReadOnly _FatChain As List(Of UInteger)
6464
Private ReadOnly _Offset As UInteger
6565
Private ReadOnly _Parent As Disk
@@ -294,15 +294,27 @@ Namespace DiskImage
294294
Return CreationDate <> 0 Or CreationTime <> 0 Or CreationMillisecond <> 0
295295
End Function
296296

297+
Public Function HasInvalidAttributes() As Boolean
298+
Return (Attributes > 63)
299+
End Function
300+
297301
Public Function HasInvalidExtension() As Boolean
298302
Dim Result As Boolean = False
299303
Dim LocalExtension = Extension
304+
Dim VolumeName As Boolean = IsVolumeName()
305+
Dim C As Byte
300306

301307
For Counter = 0 To UBound(LocalExtension)
302-
If LocalExtension(Counter) < &H20 Then
308+
C = LocalExtension(Counter)
309+
If VolumeName And (C = &H0) Then
310+
Result = False
311+
ElseIf C < &H20 Then
312+
Result = True
313+
Exit For
314+
ElseIf Not VolumeName And C > &H60 And C < &H7B Then
303315
Result = True
304316
Exit For
305-
ElseIf InvalidChars.Contains(LocalExtension(Counter)) Then
317+
ElseIf Not VolumeName And InvalidChars.Contains(C) Then
306318
Result = True
307319
Exit For
308320
End If
@@ -314,15 +326,23 @@ Namespace DiskImage
314326
Public Function HasInvalidFilename() As Boolean
315327
Dim Result As Boolean = False
316328
Dim LocalFileName = FileName
329+
Dim VolumeName As Boolean = IsVolumeName()
330+
Dim C As Byte
317331

318-
If LocalFileName(0) = &H20 Then
332+
If Not VolumeName And LocalFileName(0) = &H20 Then
319333
Result = True
320334
Else
321335
For Counter = 0 To UBound(LocalFileName)
322-
If LocalFileName(Counter) < &H20 Then
336+
C = LocalFileName(Counter)
337+
If VolumeName And (C = &H0 Or (Counter = 1 And C = &H3)) Then
338+
Result = False
339+
ElseIf C < &H20 Then
340+
Result = True
341+
Exit For
342+
ElseIf Not VolumeName And C > &H60 And C < &H7B Then
323343
Result = True
324344
Exit For
325-
ElseIf InvalidChars.Contains(LocalFileName(Counter)) Then
345+
ElseIf Not VolumeName And InvalidChars.Contains(C) Then
326346
Result = True
327347
Exit For
328348
End If
@@ -333,34 +353,15 @@ Namespace DiskImage
333353
End Function
334354

335355
Public Function HasInvalidFileSize() As Boolean
336-
Dim Result As Boolean
337-
338-
Select Case _Parent.BootSector.MediaDescriptor
339-
Case &HF0
340-
If _Parent.BootSector.SectorsPerTrack = 36 Then
341-
Result = (FileSize > 2949120)
342-
Else
343-
Result = (FileSize > 1474560)
344-
End If
345-
Case &HF9
346-
If _Parent.BootSector.SectorsPerTrack = 15 Then
347-
Result = (FileSize > 1228800)
348-
Else
349-
Result = (FileSize > 737280)
350-
End If
351-
Case &HFC
352-
Result = (FileSize > 184320)
353-
Case &HFD
354-
Result = (FileSize > 368640)
355-
Case &HFE
356-
Result = (FileSize > 163840)
357-
Case &HFF
358-
Result = (FileSize > 327680)
359-
Case Else
360-
Result = (FileSize > 2949120)
361-
End Select
356+
Dim SectorCount As UInteger
362357

363-
Return Result
358+
If _Parent.BootSector.SmallNumberOfSectors > 0 Then
359+
SectorCount = _Parent.BootSector.SmallNumberOfSectors
360+
Else
361+
SectorCount = _Parent.BootSector.LargeNumberOfSectors
362+
End If
363+
364+
Return FileSize > SectorCount * _Parent.BootSector.BytesPerSector
364365
End Function
365366

366367
Public Function HasLastAccessDate() As Boolean

DiskImageTool/DiskImageTool.vbproj

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
<TargetCulture>en-US</TargetCulture>
3030
<ProductName>DiskImageTool</ProductName>
3131
<PublisherName>Digitoxin</PublisherName>
32-
<ApplicationRevision>1</ApplicationRevision>
33-
<ApplicationVersion>1.1.0.%2a</ApplicationVersion>
32+
<ApplicationRevision>2</ApplicationRevision>
33+
<ApplicationVersion>1.2.0.%2a</ApplicationVersion>
3434
<UseApplicationTrust>false</UseApplicationTrust>
3535
<PublishWizardCompleted>true</PublishWizardCompleted>
3636
<BootstrapperEnabled>true</BootstrapperEnabled>
@@ -105,12 +105,14 @@
105105
<Import Include="System.Threading.Tasks" />
106106
</ItemGroup>
107107
<ItemGroup>
108-
<Compile Include="BootSector.vb" />
109-
<Compile Include="ComboFileItem.vb" />
108+
<Compile Include="ComboFileType.vb" />
109+
<Compile Include="DiskImage\BootSector.vb" />
110+
<Compile Include="OEMIDLookup.vb" />
111+
<Compile Include="LoadedImageData.vb" />
110112
<Compile Include="CRC32.vb" />
111-
<Compile Include="Directory.vb" />
112-
<Compile Include="DirectoryEntry.vb" />
113-
<Compile Include="Disk.vb" />
113+
<Compile Include="DiskImage\Directory.vb" />
114+
<Compile Include="DiskImage\DirectoryEntry.vb" />
115+
<Compile Include="DiskImage\Disk.vb" />
114116
<Compile Include="MainForm.vb">
115117
<SubType>Form</SubType>
116118
</Compile>
Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Public Class ComboFileItem
1+
Public Class LoadedImageData
22
Private _Path As String
33
Private _File As String
44
Private _Modified As Boolean
@@ -10,6 +10,26 @@
1010
Private _HasCreated As Boolean
1111
Private _HasLastAccessed As Boolean
1212
Private _HasLongFileNames As Boolean
13+
Public Property HasInvalidDirectoryEntries As Boolean
14+
Get
15+
Return _HasInvalidDirectoryEntries
16+
End Get
17+
Set
18+
_HasInvalidDirectoryEntries = Value
19+
End Set
20+
End Property
21+
22+
Private _ComboIndex As Integer
23+
Private _HasInvalidDirectoryEntries As Boolean
24+
25+
Public Property ComboIndex As Integer
26+
Get
27+
Return _ComboIndex
28+
End Get
29+
Set
30+
_ComboIndex = Value
31+
End Set
32+
End Property
1333

1434
Public Property HasLongFileNames As Boolean
1535
Get
@@ -122,6 +142,8 @@
122142
_HasLastAccessed = False
123143
_HasLongFileNames = False
124144
_Disk = Nothing
145+
_HasInvalidDirectoryEntries = False
146+
_ComboIndex = -1
125147
End Sub
126148
Public Overrides Function ToString() As String
127149
Return _File & IIf(_Modified, " *", "")

0 commit comments

Comments
 (0)