@@ -5,11 +5,10 @@ Namespace DiskImage
55 Public Class DirectoryEntryBase
66 Public Const CHAR_DELETED As Byte = &HE5
77 Public Const DIRECTORY_ENTRY_SIZE As Byte = 32
8- Public Shared ReadOnly EmptyDirectoryEntry() As Byte = { &HE5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }
98 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 }
9+ Public Shared ReadOnly EmptyDirectoryEntry () As Byte = { &HE5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }
1110 Public Shared ReadOnly InvalidFileChars() As Byte = { &H22 , &H2A , &H2B , &H2C , &H2E , &H2F , &H3A , &H3B , &H3C , &H3D , &H3E , &H3F , &H5B , &H5C , &H5D , &H7C }
12-
11+ Public Shared ReadOnly ParentDirectoryEntry() As Byte = { &H2E , &H2E , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 , &H20 }
1312 Private Const CHAR_EMPTY As Byte = &H0
1413 Private Const CHAR_SPACE As Byte = &H20
1514
@@ -27,6 +26,7 @@ Namespace DiskImage
2726 Private _Offset As UInteger
2827 Private _VolumeNameCache As String
2928 Private _VolumeNameIsCached As Boolean = False
29+
3030 Public Enum AttributeFlags As Byte
3131 [ReadOnly] = 1
3232 Hidden = 2
@@ -221,6 +221,84 @@ Namespace DiskImage
221221 End Set
222222 End Property
223223
224+ Public Property HasNTLowerCaseExtension As Boolean
225+ Get
226+ Return (ReservedForWinNT And NTFlags.LowerCaseExtension) > 0
227+ End Get
228+ Set (value As Boolean )
229+ ReservedForWinNT = MyBitConverter.ToggleBit(ReservedForWinNT, NTFlags.LowerCaseExtension, value)
230+ End Set
231+ End Property
232+
233+ Public Property HasNTLowerCaseFileName As Boolean
234+ Get
235+ Return (ReservedForWinNT And NTFlags.LowerCaseFileName) > 0
236+ End Get
237+ Set (value As Boolean )
238+ ReservedForWinNT = MyBitConverter.ToggleBit(ReservedForWinNT, NTFlags.LowerCaseFileName, value)
239+ End Set
240+ End Property
241+
242+ Public Property IsArchive As Boolean
243+ Get
244+ Return (Attributes And AttributeFlags.ArchiveFlag) > 0
245+ End Get
246+ Set (value As Boolean )
247+ Attributes = MyBitConverter.ToggleBit(Attributes, AttributeFlags.ArchiveFlag, value)
248+ End Set
249+ End Property
250+
251+ Public Property IsDirectory As Boolean
252+ Get
253+ Return (Attributes And AttributeFlags.Directory) > 0
254+ End Get
255+ Set (value As Boolean )
256+ Attributes = MyBitConverter.ToggleBit(Attributes, AttributeFlags.Directory, value)
257+ End Set
258+ End Property
259+
260+ Public Property IsHidden As Boolean
261+ Get
262+ Return (Attributes And AttributeFlags.Hidden) > 0
263+ End Get
264+ Set (value As Boolean )
265+ Attributes = MyBitConverter.ToggleBit(Attributes, AttributeFlags.Hidden, value)
266+ End Set
267+ End Property
268+
269+ Public ReadOnly Property IsLFN As Boolean
270+ Get
271+ Return (Attributes And AttributeFlags.LongFileName) = AttributeFlags.LongFileName
272+ End Get
273+ End Property
274+
275+ Public Property IsReadOnly As Boolean
276+ Get
277+ Return (Attributes And AttributeFlags.ReadOnly) > 0
278+ End Get
279+ Set (value As Boolean )
280+ Attributes = MyBitConverter.ToggleBit(Attributes, AttributeFlags.ReadOnly, value)
281+ End Set
282+ End Property
283+
284+ Public Property IsSystem As Boolean
285+ Get
286+ Return (Attributes And AttributeFlags.System) > 0
287+ End Get
288+ Set (value As Boolean )
289+ Attributes = MyBitConverter.ToggleBit(Attributes, AttributeFlags.System, value)
290+ End Set
291+ End Property
292+
293+ Public Property IsVolumeName As Boolean
294+ Get
295+ Return (Attributes And AttributeFlags.VolumeName) > 0
296+ End Get
297+ Set (value As Boolean )
298+ Attributes = MyBitConverter.ToggleBit(Attributes, AttributeFlags.VolumeName, value)
299+ End Set
300+ End Property
301+
224302 Public Property LastAccessDate() As UShort
225303 Get
226304 Return _FileBytes.GetBytesShort(_Offset + DirectoryEntryOffsets.LastAccessDate)
@@ -386,24 +464,6 @@ Namespace DiskImage
386464 Return File
387465 End Function
388466
389- Public Function GetNTFileName() As String
390- Dim File = GetFileName()
391- Dim Ext = GetFileExtension()
392-
393- If HasNTLowerCaseFileName() Then
394- File = File.ToLower
395- End If
396-
397- If Ext <> "" Then
398- If HasNTLowerCaseExtension() Then
399- Ext = Ext.ToLower
400- End If
401- File = File & "." & Ext
402- End If
403-
404- Return File
405- End Function
406-
407467 Public Function GetLastAccessDate() As ExpandedDate
408468 If Not _LastAccessDateIsCached Then
409469 _LastAccessDateCache = ExpandDate(LastAccessDate)
@@ -435,7 +495,7 @@ Namespace DiskImage
435495 End Function
436496
437497 Public Function GetLFNFileName() As String
438- If IsLFN() Then
498+ If IsLFN Then
439499 Dim Size As Integer = LFNSizes.FilePart1 + LFNSizes.FilePart2 + LFNSizes.FilePart3
440500 Dim LFN(Size - 1 ) As Byte
441501
@@ -451,6 +511,23 @@ Namespace DiskImage
451511 End If
452512 End Function
453513
514+ Public Function GetNTFileName() As String
515+ Dim File = GetFileName()
516+ Dim Ext = GetFileExtension()
517+
518+ If HasNTLowerCaseFileName() Then
519+ File = File.ToLower
520+ End If
521+
522+ If Ext <> "" Then
523+ If HasNTLowerCaseExtension() Then
524+ Ext = Ext.ToLower
525+ End If
526+ File = File & "." & Ext
527+ End If
528+
529+ Return File
530+ End Function
454531 Public Function GetVolumeName() As String
455532 If Not _VolumeNameIsCached Then
456533 _VolumeNameCache = CodePage437ToUnicode(FileNameWithExtension).TrimEnd( " " )
@@ -470,15 +547,15 @@ Namespace DiskImage
470547
471548 Public Function HasInvalidExtension() As Boolean
472549 If Not _HasInvalidExtensionCache.HasValue Then
473- _HasInvalidExtensionCache = Not CheckValidFileName(Extension, True , IsVolumeName() )
550+ _HasInvalidExtensionCache = Not CheckValidFileName(Extension, True , IsVolumeName)
474551 End If
475552
476553 Return _HasInvalidExtensionCache
477554 End Function
478555
479556 Public Function HasInvalidFilename() As Boolean
480557 If Not _HasInvalidFileNameCache.HasValue Then
481- _HasInvalidFileNameCache = Not CheckValidFileName(FileName, False , IsVolumeName() )
558+ _HasInvalidFileNameCache = Not CheckValidFileName(FileName, False , IsVolumeName)
482559 End If
483560
484561 Return _HasInvalidFileNameCache
@@ -487,23 +564,10 @@ Namespace DiskImage
487564 Public Function HasLastAccessDate() As Boolean
488565 Return LastAccessDate <> 0
489566 End Function
490-
491- Public Function HasNTLowerCaseFileName() As Boolean
492- Return (ReservedForWinNT And NTFlags.LowerCaseFileName) > 0
493- End Function
494-
495- Public Function HasNTLowerCaseExtension() As Boolean
496- Return (ReservedForWinNT And NTFlags.LowerCaseExtension) > 0
497- End Function
498-
499567 Public Function HasNTUnknownFlags() As Boolean
500568 Return (ReservedForWinNT And &HE7 ) > 0
501569 End Function
502570
503- Public Function IsArchive() As Boolean
504- Return (Attributes And AttributeFlags.ArchiveFlag) > 0
505- End Function
506-
507571 Public Function IsBlank() As Boolean
508572 If _IsBlankCache.HasValue Then
509573 Return _IsBlankCache.Value
@@ -535,22 +599,10 @@ Namespace DiskImage
535599 Return FileName( 0 ) = CHAR_DELETED
536600 End Function
537601
538- Public Function IsDirectory() As Boolean
539- Return (Attributes And AttributeFlags.Directory) > 0
540- End Function
541-
542602 Public Function IsEmpty() As Boolean
543603 Return FileName( 0 ) = CHAR_EMPTY
544604 End Function
545605
546- Public Function IsHidden() As Boolean
547- Return (Attributes And AttributeFlags.Hidden) > 0
548- End Function
549-
550- Public Function IsLFN() As Boolean
551- Return (Attributes And AttributeFlags.LongFileName) = AttributeFlags.LongFileName
552- End Function
553-
554606 Public Function IsLink() As Boolean
555607 Dim FilePart = _FileBytes.ToUInt16(_Offset)
556608 Return (FilePart = &H202E Or FilePart = &H2E2E )
@@ -561,20 +613,8 @@ Namespace DiskImage
561613 Return (FilePart = &H2E2E )
562614 End Function
563615
564- Public Function IsReadOnly() As Boolean
565- Return (Attributes And AttributeFlags.ReadOnly) > 0
566- End Function
567-
568- Public Function IsSystem() As Boolean
569- Return (Attributes And AttributeFlags.System) > 0
570- End Function
571-
572616 Public Function IsValidVolumeName() As Boolean
573- Return IsVolumeName() AndAlso Not (IsHidden() OrElse IsSystem() OrElse IsDirectory() OrElse IsDeleted()) AndAlso StartingCluster = 0
574- End Function
575-
576- Public Function IsVolumeName() As Boolean
577- Return (Attributes And AttributeFlags.VolumeName) > 0
617+ Return IsVolumeName AndAlso Not (IsHidden OrElse IsSystem OrElse IsDirectory OrElse IsDeleted()) AndAlso StartingCluster = 0
578618 End Function
579619
580620 Public Sub RemoveNTExtensions()
0 commit comments