1
1
Imports System.Runtime.InteropServices
2
2
3
- Public Structure FAT12
3
+ Public Class FAT12
4
4
Public Enum EntryAttributes As Byte
5
5
[ReadOnly] = 2 ^ 0
6
6
Hidden = 2 ^ 1
@@ -16,7 +16,7 @@ Public Structure FAT12
16
16
Public SectorsPerCluster As Byte
17
17
Public ReservedSectors As UInt16
18
18
Public NumberOfFATCopies As Byte
19
- Public RootEntries As UInt16
19
+ Public MaxRootEntries As UInt16
20
20
Public TotalSectors As UInt16
21
21
Public MediaDescriptor As Byte
22
22
Public SectorsPerFAT As UInt16
@@ -64,6 +64,12 @@ Public Structure FAT12
64
64
Public StartingCluster As UInt16
65
65
Public FileSize As UInt32
66
66
67
+ Public ReadOnly Property StartingClusterValue As Integer
68
+ Get
69
+ Return StartingCluster
70
+ End Get
71
+ End Property
72
+
67
73
Public ReadOnly Property FileName As String
68
74
Get
69
75
Return Text.Encoding.ASCII.GetString(FileNameChars).TrimEnd()
@@ -134,7 +140,7 @@ Public Structure FAT12
134
140
End Function
135
141
136
142
Public Shared Operator =(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
137
- Return d1.Attribute = d2.Attribute AndAlso d1.StartingCluster = d2.StartingCluster
143
+ Return d1.Attribute = d2.Attribute AndAlso d1.StartingClusterValue = d2.StartingClusterValue
138
144
End Operator
139
145
140
146
Public Shared Operator <>(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
@@ -157,58 +163,13 @@ Public Structure FAT12
157
163
End Get
158
164
End Property
159
165
End Structure
160
- End Structure
161
-
162
- Public Structure FAT16
163
- Public Enum EntryAttributes As Byte
164
- [ReadOnly] = 2 ^ 0
165
- Hidden = 2 ^ 1
166
- System = 2 ^ 2
167
- VolumeName = 2 ^ 3
168
- Directory = 2 ^ 4
169
- ArchiveFlag = 2 ^ 5
170
- End Enum
171
-
172
- <StructLayout(LayoutKind.Sequential, Pack:= 1 )>
173
- Public Structure ParameterBlock
174
- Public BytesPerSector As UInt16
175
- Public SectorsPerCluster As Byte
176
- Public ReservedSectors As UInt16
177
- Public NumberOfFATCopies As Byte
178
- Public RootEntries As UInt16
179
- Public TotalSectors As UInt16
180
- Public MediaDescriptor As Byte
181
- Public SectorsPerFAT As UInt16
182
- Public SectorsPerTrack As UInt16
183
- Public HeadsPerCylinder As UInt16
184
- Public HiddenSectors As UInt32
185
- Public TotalSectorsBig As UInt32
186
- End Structure
187
-
188
- <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:= 1 )>
189
- Public Structure ExtendedParameterBlock
190
- Public DriveNumber As Byte
191
- Public Reserved As Byte
192
- Public ExtendedBootSignature As Byte
193
- Public SerialNumber As UInt32
194
- <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 11 )> Private ReadOnly VolumeLabelChars() As Byte
195
- <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 8 )> Private ReadOnly FileSystemTypeChars() As Byte
166
+ End Class
196
167
197
- Public ReadOnly Property VolumeLabel As String
198
- Get
199
- Return Text.Encoding.ASCII.GetString(VolumeLabelChars).TrimEnd()
200
- End Get
201
- End Property
202
-
203
- Public ReadOnly Property FileSystemType As String
204
- Get
205
- Return Text.Encoding.ASCII.GetString(FileSystemTypeChars).TrimEnd()
206
- End Get
207
- End Property
208
- End Structure
168
+ Public Class FAT16
169
+ Inherits FAT12
209
170
210
171
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:= 1 )>
211
- Public Structure DirectoryEntry
172
+ Public Shadows Structure DirectoryEntry
212
173
<MarshalAs(UnmanagedType.ByValArray, SizeConst:= 8 )> Public FileNameChars() As Byte
213
174
<MarshalAs(UnmanagedType.ByValArray, SizeConst:= 3 )> Private ReadOnly FileExtensionChars() As Byte
214
175
Public Attribute As EntryAttributes
@@ -223,6 +184,12 @@ Public Structure FAT16
223
184
Public StartingCluster As UInt16
224
185
Public FileSize As UInt32
225
186
187
+ Public ReadOnly Property StartingClusterValue As Integer
188
+ Get
189
+ Return StartingCluster
190
+ End Get
191
+ End Property
192
+
226
193
Public ReadOnly Property FileName As String
227
194
Get
228
195
Return Text.Encoding.ASCII.GetString(FileNameChars).TrimEnd()
@@ -293,100 +260,70 @@ Public Structure FAT16
293
260
End Function
294
261
295
262
Public Shared Operator =(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
296
- Return d1.Attribute = d2.Attribute AndAlso d1.StartingCluster = d2.StartingCluster
263
+ Return d1.Attribute = d2.Attribute AndAlso d1.StartingClusterValue = d2.StartingClusterValue
297
264
End Operator
298
265
299
266
Public Shared Operator <>(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
300
267
Return Not d1 = d2
301
268
End Operator
302
269
End Structure
270
+ End Class
303
271
304
- <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:= 1 )>
305
- Public Structure BootSector
306
- <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 3 )> Public JumpCode() As Byte
307
- <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 8 )> Private ReadOnly OemIdChars() As Byte
308
- <MarshalAs(UnmanagedType.Struct)> Public BIOSParameterBlock As ParameterBlock
309
- <MarshalAs(UnmanagedType.Struct)> Public ExtendedBIOSParameterBlock As ExtendedParameterBlock
310
- <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 448 )> Public BootStrapCode() As Byte
311
- Public Signature As UInt16
312
-
313
- Public ReadOnly Property OemId As String
314
- Get
315
- Return Text.Encoding.ASCII.GetString(OemIdChars).TrimEnd()
316
- End Get
317
- End Property
318
- End Structure
319
- End Structure
320
-
321
- Public Structure FAT32
322
- Public Enum EntryAttributes As Byte
323
- [ReadOnly] = 2 ^ 0
324
- Hidden = 2 ^ 1
325
- System = 2 ^ 2
326
- VolumeName = 2 ^ 3
327
- Directory = 2 ^ 4
328
- ArchiveFlag = 2 ^ 5
329
- End Enum
272
+ Public Class FAT32
273
+ Inherits FAT12
330
274
331
275
<StructLayout(LayoutKind.Sequential, Pack:= 1 )>
332
- Public Structure ParameterBlock
276
+ Public Shadows Structure ParameterBlock
333
277
Public BytesPerSector As UInt16
334
278
Public SectorsPerCluster As Byte
335
279
Public ReservedSectors As UInt16
336
280
Public NumberOfFATCopies As Byte
337
- Public RootEntries As UInt16
338
- Public TotalSectors As UInt16
281
+ Public MaxRootEntries As UInt16 ' Not used
282
+ Public TotalSectors As UInt16 ' Not used
339
283
Public MediaDescriptor As Byte
340
- Public NotUsed As UInt16
284
+ Public SectorsPerFAT As UInt16
341
285
Public SectorsPerTrack As UInt16
342
286
Public HeadsPerCylinder As UInt16
343
287
Public HiddenSectors As UInt32
344
- Public TotalSectorsBig As UInt32
345
- Public SectorsPerFAT As UInt32
288
+ Public SectorsInPartition As UInt32
289
+ Public SectorsPerFATNew As UInt32
346
290
Public FATHandlingFlags As UInt16
347
- Public DriveVersion As UInt16
348
- Public ClusterFSIS As UInt32
349
- Public SectorBBS As UInt16
291
+ Public Version As UInt16
292
+ Public ClusterStartRootDirectory As UInt32
293
+ Public SectorStartFileSystemInformationSector As UInt16
294
+ Public SectorStartBackupBootSector As UInt16
350
295
<MarshalAs(UnmanagedType.ByValArray, SizeConst:= 12 )> Private Reserved() As Byte
351
296
End Structure
352
297
353
298
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:= 1 )>
354
- Public Structure ExtendedParameterBlock
355
- Public DriveNumber As Byte
356
- Public CurrentHead As Byte
357
- Public ExtendedBootSignature As Byte
358
- Public SerialNumber As UInt32
359
- <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 11 )> Private ReadOnly VolumeLabelChars() As Byte
360
- <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 8 )> Private ReadOnly FileSystemTypeChars() As Byte
299
+ Public Shadows Structure DirectoryEntry
300
+ <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 8 )> Public FileNameChars() As Byte
301
+ <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 3 )> Private ReadOnly FileExtensionChars() As Byte
302
+ Public Attribute As Byte
303
+ <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 8 )> Public Unused01() As Byte
304
+ Public StartingCluster As UInt16
305
+ Public CreationTime As UInt16
306
+ Public CreationDate As UInt16
307
+ Public StartingClusterLowWord As UInt16
308
+ Public FileSize As UInt32
361
309
362
- Public ReadOnly Property VolumeLabel As String
310
+ Public ReadOnly Property StartingClusterValue As Integer
363
311
Get
364
- Return Text.Encoding.ASCII.GetString(VolumeLabelChars).TrimEnd()
312
+ Return (StartingCluster << 8 ) Or StartingClusterLowWord
365
313
End Get
366
314
End Property
367
315
368
- Public ReadOnly Property FileSystemType As String
316
+ Public ReadOnly Property LastWriteTime As UInt16
369
317
Get
370
- Return Text.Encoding.ASCII.GetString(FileSystemTypeChars).TrimEnd()
318
+ Return CreationTime
371
319
End Get
372
320
End Property
373
- End Structure
374
321
375
- <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:= 1 )>
376
- Public Structure DirectoryEntry
377
- <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 8 )> Public FileNameChars() As Byte
378
- <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 3 )> Private ReadOnly FileExtensionChars() As Byte
379
- Public Attribute As EntryAttributes
380
- Public ReservedNT As Byte
381
- Public Creation As Byte
382
- Public CreationTime As UInt16
383
- Public CreationDate As UInt16
384
- Public LastAccessDate As UInt16
385
- Public ReservedFAT32 As UInt16
386
- Public LastWriteTime As UInt16
387
- Public LastWriteDate As UInt16
388
- Public StartingCluster As UInt16
389
- Public FileSize As UInt32
322
+ Public ReadOnly Property LastWriteDate As UInt16
323
+ Get
324
+ Return CreationDate
325
+ End Get
326
+ End Property
390
327
391
328
Public ReadOnly Property FileName As String
392
329
Get
@@ -422,6 +359,7 @@ Public Structure FAT32
422
359
Get
423
360
Dim t() As Integer = FSTimeToNative(LastWriteTime)
424
361
Dim d() As Integer = FSDateToNative(LastWriteDate)
362
+
425
363
Try
426
364
Return New DateTime(d( 0 ), d( 1 ), d( 2 ), t( 0 ), t( 1 ), t( 2 ))
427
365
Catch
@@ -458,7 +396,7 @@ Public Structure FAT32
458
396
End Function
459
397
460
398
Public Shared Operator =(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
461
- Return d1.Attribute = d2.Attribute AndAlso d1.StartingCluster = d2.StartingCluster
399
+ Return d1.Attribute = d2.Attribute AndAlso d1.StartingClusterValue = d2.StartingClusterValue
462
400
End Operator
463
401
464
402
Public Shared Operator <>(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
@@ -467,12 +405,12 @@ Public Structure FAT32
467
405
End Structure
468
406
469
407
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:= 1 )>
470
- Public Structure BootSector
408
+ Public Shadows Structure BootSector
471
409
<MarshalAs(UnmanagedType.ByValArray, SizeConst:= 3 )> Public JumpCode() As Byte
472
410
<MarshalAs(UnmanagedType.ByValArray, SizeConst:= 8 )> Private ReadOnly OemIdChars() As Byte
473
411
<MarshalAs(UnmanagedType.Struct)> Public BIOSParameterBlock As ParameterBlock
474
412
<MarshalAs(UnmanagedType.Struct)> Public ExtendedBIOSParameterBlock As ExtendedParameterBlock
475
- <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 448 )> Public BootStrapCode() As Byte
413
+ <MarshalAs(UnmanagedType.ByValArray, SizeConst:= 420 )> Public BootStrapCode() As Byte
476
414
Public Signature As UInt16
477
415
478
416
Public ReadOnly Property OemId As String
@@ -481,4 +419,4 @@ Public Structure FAT32
481
419
End Get
482
420
End Property
483
421
End Structure
484
- End Structure
422
+ End Class
0 commit comments