Skip to content

Commit 8657db9

Browse files
committed
Bug fixes
1 parent 1597cb4 commit 8657db9

File tree

7 files changed

+88
-45
lines changed

7 files changed

+88
-45
lines changed

DiskImageTool/DiskImage/Functions.vb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,18 @@ Namespace DiskImage
395395
Return Content
396396
End Function
397397

398-
Public Function GetDirectoryEntryCount(FileBytes As ByteArray, OffsetStart As UInteger, OffsetEnd As UInteger, FileCountOnly As Boolean) As UInteger
398+
Public Function GetDirectoryEntryCount(FileBytes As ByteArray, OffsetStart As UInteger, OffsetEnd As UInteger, FileCountOnly As Boolean, ExcludeDeleted As Boolean) As UInteger
399399
Dim Count As UInteger = 0
400400

401401
Do While FileBytes.GetByte(OffsetStart) > 0
402-
If Not FileCountOnly Then
403-
Count += 1
404-
ElseIf FileBytes.GetByte(OffsetStart + 11) <> &HF Then 'Exclude LFN entries
405-
Dim FilePart = FileBytes.ToUInt16(OffsetStart)
406-
If FilePart <> &H202E And FilePart <> &H2E2E Then 'Exclude '.' and '..' entries
402+
If Not ExcludeDeleted OrElse FileBytes.GetByte(OffsetStart) <> &HE5 Then
403+
If Not FileCountOnly Then
407404
Count += 1
405+
ElseIf FileBytes.GetByte(OffsetStart + 11) <> &HF Then 'Exclude LFN entries
406+
Dim FilePart = FileBytes.ToUInt16(OffsetStart)
407+
If FilePart <> &H202E And FilePart <> &H2E2E Then 'Exclude '.' and '..' entries
408+
Count += 1
409+
End If
408410
End If
409411
End If
410412
OffsetStart += 32

DiskImageTool/DiskImage/IDirectory.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Public Interface IDirectory
33
ReadOnly Property SectorChain As List(Of UInteger)
44
Function DirectoryEntryCount() As UInteger
5-
Function FileCount() As UInteger
5+
Function FileCount(ExcludeDeleted As Boolean) As UInteger
66
Function GetContent() As Byte()
77
Function GetFile(Index As UInteger) As DirectoryEntry
88
Function HasFile(Filename As String) As Boolean

DiskImageTool/DiskImage/RootDirectory.vb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
End Property
2626

2727
Public Function DirectoryEntryCount() As UInteger Implements IDirectory.DirectoryEntryCount
28-
Return GetDirectoryEntryCount(False)
28+
Return GetDirectoryEntryCount(False, False)
2929
End Function
3030

31-
Public Function FileCount() As UInteger Implements IDirectory.FileCount
32-
Return GetDirectoryEntryCount(True)
31+
Public Function FileCount(ExcludeDeleted As Boolean) As UInteger Implements IDirectory.FileCount
32+
Return GetDirectoryEntryCount(True, ExcludeDeleted)
3333
End Function
3434

3535
Public Function GetContent() As Byte() Implements IDirectory.GetContent
@@ -48,7 +48,7 @@
4848
End Function
4949

5050
Public Function HasFile(Filename As String) As Boolean Implements IDirectory.HasFile
51-
Dim Count = GetDirectoryEntryCount(False)
51+
Dim Count = GetDirectoryEntryCount(False, False)
5252
If Count > 0 Then
5353
For Counter As UInteger = 0 To Count - 1
5454
Dim File = GetFile(Counter)
@@ -63,11 +63,11 @@
6363
Return False
6464
End Function
6565

66-
Private Function GetDirectoryEntryCount(FileCountOnly As Boolean) As UInteger
66+
Private Function GetDirectoryEntryCount(FileCountOnly As Boolean, ExcludeDeleted As Boolean) As UInteger
6767
Dim OffsetStart As UInteger = SectorToBytes(_BootSector.RootDirectoryRegionStart)
6868
Dim OffsetEnd As UInteger = SectorToBytes(_BootSector.DataRegionStart)
6969

70-
Return Functions.GetDirectoryEntryCount(_FileBytes, OffsetStart, OffsetEnd, FileCountOnly)
70+
Return Functions.GetDirectoryEntryCount(_FileBytes, OffsetStart, OffsetEnd, FileCountOnly, ExcludeDeleted)
7171
End Function
7272
End Class
7373
End Namespace

DiskImageTool/DiskImage/SubDirectory.vb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
End Property
2424

2525
Public Function DirectoryEntryCount() As UInteger Implements IDirectory.DirectoryEntryCount
26-
Return GetDirectoryEntryCount(False)
26+
Return GetDirectoryEntryCount(False, False)
2727
End Function
2828

29-
Public Function FileCount() As UInteger Implements IDirectory.FileCount
30-
Return GetDirectoryEntryCount(True)
29+
Public Function FileCount(ExcludeDeleted As Boolean) As UInteger Implements IDirectory.FileCount
30+
Return GetDirectoryEntryCount(True, ExcludeDeleted)
3131
End Function
3232

3333
Public Function GetContent() As Byte() Implements IDirectory.GetContent
@@ -50,7 +50,7 @@
5050
End Function
5151

5252
Public Function HasFile(Filename As String) As Boolean Implements IDirectory.HasFile
53-
Dim Count = GetDirectoryEntryCount(False)
53+
Dim Count = GetDirectoryEntryCount(False, False)
5454
For Counter As UInteger = 0 To Count - 1
5555
Dim File = GetFile(Counter)
5656
If Not File.IsDeleted And Not File.IsVolumeName And Not File.IsDirectory Then
@@ -63,14 +63,14 @@
6363
Return False
6464
End Function
6565

66-
Private Function GetDirectoryEntryCount(FileCountOnly As Boolean) As UInteger
66+
Private Function GetDirectoryEntryCount(FileCountOnly As Boolean, ExcludeDeleted As Boolean) As UInteger
6767
Dim Count As UInteger = 0
6868

6969
For Each Cluster In _FatChain.Clusters
7070
Dim OffsetStart As UInteger = _BootSector.ClusterToOffset(Cluster)
7171
Dim OffsetLength As UInteger = _BootSector.BytesPerCluster
7272

73-
Count += Functions.GetDirectoryEntryCount(_FileBytes, OffsetStart, OffsetStart + OffsetLength, FileCountOnly)
73+
Count += Functions.GetDirectoryEntryCount(_FileBytes, OffsetStart, OffsetStart + OffsetLength, FileCountOnly, ExcludeDeleted)
7474
Next
7575

7676
Return Count

DiskImageTool/Forms/FATEditForm.vb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,6 @@ Public Class FATEditForm
465465

466466
_FAT.TableEntry(Cluster) = Value
467467
_FAT.ProcessFAT12(True)
468-
For Each key In _FAT.FATChains.Keys
469-
Debug.Print(key)
470-
Next
471468

472469
RefreshGrid()
473470
PictureBoxFAT.Invalidate()

DiskImageTool/MainForm.Designer.vb

Lines changed: 22 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)