Skip to content

Commit

Permalink
Properly display the volume label in DiskExplorer
Browse files Browse the repository at this point in the history
  • Loading branch information
morphx666 committed Mar 3, 2019
1 parent fbb0fc8 commit 3536336
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 127 deletions.
4 changes: 2 additions & 2 deletions GenOpCodes/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("2019.3.2.612")>
<Assembly: AssemblyFileVersion("2019.3.2.612")>
<Assembly: AssemblyVersion("2019.3.3.617")>
<Assembly: AssemblyFileVersion("2019.3.3.617")>
4 changes: 2 additions & 2 deletions RunTests/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("2019.3.2.940")>
<Assembly: AssemblyFileVersion("2019.3.2.940")>
<Assembly: AssemblyVersion("2019.3.3.945")>
<Assembly: AssemblyFileVersion("2019.3.3.945")>
102 changes: 1 addition & 101 deletions x8086NetEmu/Adapters/Disk/FileSystem/FileSystemStructs.vb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Public Class FAT12

Public ReadOnly Property VolumeLabel As String
Get
Return Text.Encoding.ASCII.GetString(VolumeLabelChars).TrimEnd()
Return Text.Encoding.ASCII.GetString(VolumeLabelChars).Replace(vbNullChar, "").TrimEnd()
End Get
End Property

Expand Down Expand Up @@ -167,106 +167,6 @@ End Class

Public Class FAT16
Inherits FAT12

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)>
Public Shadows Structure DirectoryEntry
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public FileNameChars() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Private ReadOnly FileExtensionChars() As Byte
Public Attribute As EntryAttributes
Public ReservedNT As Byte
Public Creation As Byte
Public CreationTime As UInt16
Public CreationDate As UInt16
Public LastAccessDate As UInt16
Public ReservedFAT32 As UInt16
Public LastWriteTime As UInt16
Public LastWriteDate As UInt16
Public StartingCluster As UInt16
Public FileSize As UInt32

Public ReadOnly Property StartingClusterValue As Integer
Get
Return StartingCluster
End Get
End Property

Public ReadOnly Property FileName As String
Get
Return Text.Encoding.ASCII.GetString(FileNameChars).TrimEnd()
End Get
End Property

Public ReadOnly Property FileExtension As String
Get
Return Text.Encoding.ASCII.GetString(FileExtensionChars).TrimEnd()
End Get
End Property

Public ReadOnly Property FullFileName As String
Get
Dim fn As String = FileName.TrimEnd()
Dim fe As String = FileExtension.TrimEnd()
If fe <> "" Then fe = "." + fe

Return fn + fe
End Get
End Property

Public ReadOnly Property CreationDateTime As DateTime
Get
Dim t() As Integer = FSTimeToNative(CreationTime)
Dim d() As Integer = FSDateToNative(CreationTime)
Return New DateTime(d(2), d(1), d(0), t(2), t(1), t(0))
End Get
End Property

Public ReadOnly Property WriteDateTime As DateTime
Get
Dim t() As Integer = FSTimeToNative(LastWriteTime)
Dim d() As Integer = FSDateToNative(LastWriteDate)
Try
Return New DateTime(d(0), d(1), d(2), t(0), t(1), t(2))
Catch
Return New DateTime(1980, 1, 1, 0, 0, 0)
End Try
End Get
End Property

Private Function FSTimeToNative(v As UInt16) As Integer()
Dim s As Integer = (v And &H1F) * 2
Dim m As Integer = (v And &H3E0) >> 5
Dim h As Integer = (v And &HF800) >> 11
Return {h, m, s}
End Function

Private Function FSDateToNative(v As UInt16) As Integer()
Dim d As Integer = v And &H1F
Dim m As Integer = (v And &H1E0) >> 5
Dim y As Integer = ((v And &HFE00) >> 9) + 1980
Return {y, m, d}
End Function

Public Shadows Function ToString() As String
Dim attrs() As String = [Enum].GetNames(GetType(EntryAttributes))
Dim attr As String = ""
For i As Integer = 0 To attrs.Length - 1
If ((2 ^ i) And Attribute) <> 0 Then
attr += attrs(i) + " "
End If
Next
attr = attr.TrimEnd()

Return $"{FullFileName} [{attr}]"
End Function

Public Shared Operator =(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
Return d1.Attribute = d2.Attribute AndAlso d1.StartingClusterValue = d2.StartingClusterValue
End Operator

Public Shared Operator <>(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
Return Not d1 = d2
End Operator
End Structure
End Class

Public Class FAT32
Expand Down
4 changes: 2 additions & 2 deletions x8086NetEmu/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("2019.3.2.7008")>
<Assembly: AssemblyFileVersion("2019.3.2.7001")>
<Assembly: AssemblyVersion("2019.3.3.7013")>
<Assembly: AssemblyFileVersion("2019.3.3.7006")>
4 changes: 2 additions & 2 deletions x8086NetEmuConsole/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("2019.3.2.1002")>
<Assembly: AssemblyFileVersion("2019.3.2.997")>
<Assembly: AssemblyVersion("2019.3.3.1007")>
<Assembly: AssemblyFileVersion("2019.3.3.1002")>
4 changes: 2 additions & 2 deletions x8086NetEmuWinForms/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("2019.3.2.6694")>
<Assembly: AssemblyFileVersion("2019.3.2.6692")>
<Assembly: AssemblyVersion("2019.3.3.6706")>
<Assembly: AssemblyFileVersion("2019.3.3.6704")>
6 changes: 2 additions & 4 deletions x8086NetEmuWinForms/Tools/FormDiskExplorer.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 6 additions & 12 deletions x8086NetEmuWinForms/Tools/FormDiskExplorer.vb
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ Public Class FormDiskExplorer
AddHandler ComboBoxPartitions.SelectedIndexChanged, Sub()
selectedParitionIndex = ComboBoxPartitions.SelectedIndex

LabelVolumeLabel.Text = sdf.BootSector(selectedParitionIndex).ExtendedBIOSParameterBlock.VolumeLabel
LabelFileSystem.Text = sdf.BootSector(selectedParitionIndex).ExtendedBIOSParameterBlock.FileSystemType
Dim volName As String = sdf.BootSector(selectedParitionIndex).ExtendedBIOSParameterBlock.VolumeLabel
volName = If(volName = "", "unlabeled", volName)

LabelVolumeLabel.Text = volName
LabelFileSystem.Text = sdf.MasterBootRecord.Partitions(selectedParitionIndex).SystemId.ToString()
LabelOemId.Text = sdf.BootSector(selectedParitionIndex).OemId
LabelSerialNumber.Text = sdf.BootSector(selectedParitionIndex).ExtendedBIOSParameterBlock.SerialNumber

DecodeBootStrapCode()

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

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

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

'Dim driveNumber As Integer = sdf.BootSector(0).DriveNumber
'Dim rootNode As TreeNode = TreeViewDirs.Nodes.Add(Chr(If(driveNumber >= 128, Asc("C") + driveNumber - 128, Asc("A") + driveNumber)) + ":")
'Dim volLabels As IEnumerable(Of String) = (From de In entries
' Where (de.Attribute And FAT12_16.EntryAttributes.VolumeName) = FAT12_16.EntryAttributes.VolumeName
' Select de.FileName)

Dim node As TreeNode = Nothing
parentNode.Nodes.Clear()
ListViewFileSystem.Items.Clear()
Expand Down

0 comments on commit 3536336

Please sign in to comment.