@@ -6,6 +6,8 @@ Namespace DiskImage
66 Public Const CHAR_DELETED As Byte = &HE5
77 Public Const DIRECTORY_ENTRY_SIZE As Byte = 32
88 Public Shared ReadOnly EmptyDirectoryEntry() As Byte = { &HE5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }
9+ Public Shared ReadOnly CurrentDirectoryEntry() As Byte = { &H2E , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 }
10+ Public Shared ReadOnly ParentDirectoryEntry() As Byte = { &H2E , &H2E , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 }
911
1012 Private Const CHAR_EMPTY As Byte = &H0
1113 Private Const CHAR_SPACE As Byte = &H20
@@ -99,6 +101,11 @@ Namespace DiskImage
99101 _Offset = 0
100102 End Sub
101103
104+ Sub New (Data() As Byte )
105+ _FileBytes = New ByteArray(Data)
106+ _Offset = 0
107+ End Sub
108+
102109 Sub New (FileBytes As IByteArray, Offset As UInteger)
103110 _FileBytes = FileBytes
104111 _Offset = Offset
@@ -190,6 +197,20 @@ Namespace DiskImage
190197 End Set
191198 End Property
192199
200+ Public Property FileNameWithExtension() As Byte ()
201+ Get
202+ Return _FileBytes.GetBytes(_Offset + DirectoryEntryOffsets.FileName, DirectoryEntrySizes.FileName + DirectoryEntrySizes.Extension)
203+ End Get
204+ Set
205+ If _FileBytes.SetBytes(Value, _Offset + DirectoryEntryOffsets.FileName, DirectoryEntrySizes.FileName + DirectoryEntrySizes.Extension, CHAR_SPACE) Then
206+ _IsBlankCache = Nothing
207+ _VolumeNameIsCached = False
208+ _FileNameIsCached = False
209+ _HasInvalidFileNameCache = Nothing
210+ End If
211+ End Set
212+ End Property
213+
193214 Public Property FileSize() As UInteger
194215 Get
195216 Return _FileBytes.GetBytesInteger(_Offset + DirectoryEntryOffsets.FileSize)
@@ -326,6 +347,10 @@ Namespace DiskImage
326347 LastWriteTime = 0
327348 End Sub
328349
350+ Public Function Clone() As DirectoryEntryBase
351+ Return New DirectoryEntryBase(Data)
352+ End Function
353+
329354 Public Function GetCreationDate() As ExpandedDate
330355 If Not _CreationDateIsCached Then
331356 _CreationDateCache = ExpandDate(CreationDate, CreationTime, CreationMillisecond)
@@ -413,7 +438,7 @@ Namespace DiskImage
413438
414439 Public Function GetVolumeName() As String
415440 If Not _VolumeNameIsCached Then
416- _VolumeNameCache = ( CodePage437ToUnicode(FileName) & CodePage437ToUnicode(Extension) ).TrimEnd(" " )
441+ _VolumeNameCache = CodePage437ToUnicode(FileNameWithExtension ).TrimEnd( " " )
417442 _VolumeNameIsCached = True
418443 End If
419444
@@ -517,6 +542,10 @@ Namespace DiskImage
517542 Return (Attributes And AttributeFlags.System) > 0
518543 End Function
519544
545+ Public Function IsValidVolumeName() As Boolean
546+ Return IsVolumeName() AndAlso Not (IsHidden() OrElse IsSystem() OrElse IsDirectory() OrElse IsDeleted()) AndAlso StartingCluster = 0
547+ End Function
548+
520549 Public Function IsVolumeName() As Boolean
521550 Return (Attributes And AttributeFlags.VolumeName) > 0
522551 End Function
0 commit comments