Skip to content

Commit 3536336

Browse files
committed
Properly display the volume label in DiskExplorer
1 parent fbb0fc8 commit 3536336

File tree

8 files changed

+19
-127
lines changed

8 files changed

+19
-127
lines changed

GenOpCodes/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2019.3.2.612")>
35-
<Assembly: AssemblyFileVersion("2019.3.2.612")>
34+
<Assembly: AssemblyVersion("2019.3.3.617")>
35+
<Assembly: AssemblyFileVersion("2019.3.3.617")>

RunTests/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2019.3.2.940")>
35-
<Assembly: AssemblyFileVersion("2019.3.2.940")>
34+
<Assembly: AssemblyVersion("2019.3.3.945")>
35+
<Assembly: AssemblyFileVersion("2019.3.3.945")>

x8086NetEmu/Adapters/Disk/FileSystem/FileSystemStructs.vb

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Public Class FAT12
3737

3838
Public ReadOnly Property VolumeLabel As String
3939
Get
40-
Return Text.Encoding.ASCII.GetString(VolumeLabelChars).TrimEnd()
40+
Return Text.Encoding.ASCII.GetString(VolumeLabelChars).Replace(vbNullChar, "").TrimEnd()
4141
End Get
4242
End Property
4343

@@ -167,106 +167,6 @@ End Class
167167

168168
Public Class FAT16
169169
Inherits FAT12
170-
171-
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)>
172-
Public Shadows Structure DirectoryEntry
173-
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public FileNameChars() As Byte
174-
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Private ReadOnly FileExtensionChars() As Byte
175-
Public Attribute As EntryAttributes
176-
Public ReservedNT As Byte
177-
Public Creation As Byte
178-
Public CreationTime As UInt16
179-
Public CreationDate As UInt16
180-
Public LastAccessDate As UInt16
181-
Public ReservedFAT32 As UInt16
182-
Public LastWriteTime As UInt16
183-
Public LastWriteDate As UInt16
184-
Public StartingCluster As UInt16
185-
Public FileSize As UInt32
186-
187-
Public ReadOnly Property StartingClusterValue As Integer
188-
Get
189-
Return StartingCluster
190-
End Get
191-
End Property
192-
193-
Public ReadOnly Property FileName As String
194-
Get
195-
Return Text.Encoding.ASCII.GetString(FileNameChars).TrimEnd()
196-
End Get
197-
End Property
198-
199-
Public ReadOnly Property FileExtension As String
200-
Get
201-
Return Text.Encoding.ASCII.GetString(FileExtensionChars).TrimEnd()
202-
End Get
203-
End Property
204-
205-
Public ReadOnly Property FullFileName As String
206-
Get
207-
Dim fn As String = FileName.TrimEnd()
208-
Dim fe As String = FileExtension.TrimEnd()
209-
If fe <> "" Then fe = "." + fe
210-
211-
Return fn + fe
212-
End Get
213-
End Property
214-
215-
Public ReadOnly Property CreationDateTime As DateTime
216-
Get
217-
Dim t() As Integer = FSTimeToNative(CreationTime)
218-
Dim d() As Integer = FSDateToNative(CreationTime)
219-
Return New DateTime(d(2), d(1), d(0), t(2), t(1), t(0))
220-
End Get
221-
End Property
222-
223-
Public ReadOnly Property WriteDateTime As DateTime
224-
Get
225-
Dim t() As Integer = FSTimeToNative(LastWriteTime)
226-
Dim d() As Integer = FSDateToNative(LastWriteDate)
227-
Try
228-
Return New DateTime(d(0), d(1), d(2), t(0), t(1), t(2))
229-
Catch
230-
Return New DateTime(1980, 1, 1, 0, 0, 0)
231-
End Try
232-
End Get
233-
End Property
234-
235-
Private Function FSTimeToNative(v As UInt16) As Integer()
236-
Dim s As Integer = (v And &H1F) * 2
237-
Dim m As Integer = (v And &H3E0) >> 5
238-
Dim h As Integer = (v And &HF800) >> 11
239-
Return {h, m, s}
240-
End Function
241-
242-
Private Function FSDateToNative(v As UInt16) As Integer()
243-
Dim d As Integer = v And &H1F
244-
Dim m As Integer = (v And &H1E0) >> 5
245-
Dim y As Integer = ((v And &HFE00) >> 9) + 1980
246-
Return {y, m, d}
247-
End Function
248-
249-
Public Shadows Function ToString() As String
250-
Dim attrs() As String = [Enum].GetNames(GetType(EntryAttributes))
251-
Dim attr As String = ""
252-
For i As Integer = 0 To attrs.Length - 1
253-
If ((2 ^ i) And Attribute) <> 0 Then
254-
attr += attrs(i) + " "
255-
End If
256-
Next
257-
attr = attr.TrimEnd()
258-
259-
Return $"{FullFileName} [{attr}]"
260-
End Function
261-
262-
Public Shared Operator =(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
263-
Return d1.Attribute = d2.Attribute AndAlso d1.StartingClusterValue = d2.StartingClusterValue
264-
End Operator
265-
266-
Public Shared Operator <>(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
267-
Return Not d1 = d2
268-
End Operator
269-
End Structure
270170
End Class
271171

272172
Public Class FAT32

x8086NetEmu/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2019.3.2.7008")>
35-
<Assembly: AssemblyFileVersion("2019.3.2.7001")>
34+
<Assembly: AssemblyVersion("2019.3.3.7013")>
35+
<Assembly: AssemblyFileVersion("2019.3.3.7006")>

x8086NetEmuConsole/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2019.3.2.1002")>
35-
<Assembly: AssemblyFileVersion("2019.3.2.997")>
34+
<Assembly: AssemblyVersion("2019.3.3.1007")>
35+
<Assembly: AssemblyFileVersion("2019.3.3.1002")>

x8086NetEmuWinForms/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2019.3.2.6694")>
35-
<Assembly: AssemblyFileVersion("2019.3.2.6692")>
34+
<Assembly: AssemblyVersion("2019.3.3.6706")>
35+
<Assembly: AssemblyFileVersion("2019.3.3.6704")>

x8086NetEmuWinForms/Tools/FormDiskExplorer.Designer.vb

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

x8086NetEmuWinForms/Tools/FormDiskExplorer.vb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ Public Class FormDiskExplorer
2727
AddHandler ComboBoxPartitions.SelectedIndexChanged, Sub()
2828
selectedParitionIndex = ComboBoxPartitions.SelectedIndex
2929

30-
LabelVolumeLabel.Text = sdf.BootSector(selectedParitionIndex).ExtendedBIOSParameterBlock.VolumeLabel
31-
LabelFileSystem.Text = sdf.BootSector(selectedParitionIndex).ExtendedBIOSParameterBlock.FileSystemType
30+
Dim volName As String = sdf.BootSector(selectedParitionIndex).ExtendedBIOSParameterBlock.VolumeLabel
31+
volName = If(volName = "", "unlabeled", volName)
32+
33+
LabelVolumeLabel.Text = volName
34+
LabelFileSystem.Text = sdf.MasterBootRecord.Partitions(selectedParitionIndex).SystemId.ToString()
3235
LabelOemId.Text = sdf.BootSector(selectedParitionIndex).OemId
3336
LabelSerialNumber.Text = sdf.BootSector(selectedParitionIndex).ExtendedBIOSParameterBlock.SerialNumber
3437

3538
DecodeBootStrapCode()
3639

3740
Dim rootNode As TreeNode
38-
Dim volLabels As IEnumerable(Of String) = (From de As Object In sdf.RootDirectoryEntries(selectedParitionIndex)
39-
Where (de.Attribute And FAT12.EntryAttributes.VolumeName) = FAT12.EntryAttributes.VolumeName
40-
Select (de.FileName.ToString()))
4141

4242
TreeViewDirs.Nodes.Clear()
43-
rootNode = If(volLabels.Count > 0, New TreeNode(volLabels.First(), -1, -1), New TreeNode("[No Label]", -1, -1))
43+
rootNode = New TreeNode(volName, -1, -1)
4444
TreeViewDirs.Nodes.Add(rootNode)
4545

4646
DisplayFileSystem(rootNode, sdf.RootDirectoryEntries(selectedParitionIndex))
@@ -70,12 +70,6 @@ Public Class FormDiskExplorer
7070
Convert.ToByte(de.FileNameChars(0)) < &H5E
7171
Order By GetTypeDescription(de.FileExtension)
7272

73-
'Dim driveNumber As Integer = sdf.BootSector(0).DriveNumber
74-
'Dim rootNode As TreeNode = TreeViewDirs.Nodes.Add(Chr(If(driveNumber >= 128, Asc("C") + driveNumber - 128, Asc("A") + driveNumber)) + ":")
75-
'Dim volLabels As IEnumerable(Of String) = (From de In entries
76-
' Where (de.Attribute And FAT12_16.EntryAttributes.VolumeName) = FAT12_16.EntryAttributes.VolumeName
77-
' Select de.FileName)
78-
7973
Dim node As TreeNode = Nothing
8074
parentNode.Nodes.Clear()
8175
ListViewFileSystem.Items.Clear()

0 commit comments

Comments
 (0)