TCDFSFileSystem

From Ultibo.org
Jump to: navigation, search

Return to Unit CDFS


Description


To be documented

Class definitions



TCDFSFileSystem = class(TFileSystem)

constructor Create(ADriver:TFileSysDriver; AVolume:TDiskVolume; ADrive:TDiskDrive);  
destructor Destroy; override;  
private
FCDFSType:TCDFSType;  
FSwapSerial:Boolean;  
FVolumeFlags:LongWord; Volume flags
 
FTreesLoaded:Boolean;  
FBlocksLoaded:Boolean;  
FCatalogsLoaded:Boolean;  
FCatalogsLoading:Boolean;  
 
FBlockWrite:Boolean;  
FTreesPrepared:Boolean;  
FCatalogsChecked:Boolean;  
 
FLogicalBlockSize:Word; Size of a logical block on disk
FLogicalBlockCount:LongWord; Number of logical blocks on disk
 
FSectorsPerCluster:LongWord; Usually 1,2,4,8,16,32,64,128 etc
 
FDataStartCluster:LongWord; Usually 16 (First cluster of Data Area)
FBootStartCluster:LongWord; Usually 17 (Cluster of the Boot Descriptor)
FRootStartCluster:LongWord; Pointed to by Primary Descriptor
 
FBlockShiftCount:Word; Shift count for Cluster <-> BlockNo
FSectorShiftCount:Word; Shift count for Sector <-> Cluster
FClusterShiftCount:Word; Shift count for Cluster <-> Bytes
 
FEntriesPerBlock:LongWord; Number of Cluster entries per Block of bitmap
FClustersPerBlock:LongWord; Number of Clusters per Block of bitmap entries
FTotalBlockCount:LongWord; Total number of Blocks in bitmap
 
FTotalClusterCount:LongWord; Total number of Clusters on volume
 
FLastFreeCluster:LongWord; Or cdfsUnknownCluster if not known
FFreeClusterCount:LongWord; Or cdfsUnknownCluster if not known
 
FClusterSize:LongWord; Size of a Cluster in Bytes (Max 65536 > Word)
 
FBoot:TCDFSDiskDescriptor;  
FPrimary:TCDFSDiskDescriptor;  
FSupplementary:TCDFSDiskDescriptor;  
 
FHeaders:TFileSysList; List of Catalog Headers
FExtensions:TFileSysList; List of Catalog Extensions
FDescriptors:TFileSysList; List of Volume Descriptors
 
FHeaderLocal:TMutexHandle; Local Lock shared by all Catalog Headers
FExtensionLocal:TMutexHandle; Local Lock shared by all Catalog Extensions
FDescriptorLocal:TMutexHandle; Local Lock shared by all Volume Descriptors
 
FExtendedLocal:TMutexHandle; Local Lock shared by all Extended Attributes
 
FPathLock:TSynchronizerHandle; Lock shared by all Path lists
 
FReadBuffer:Pointer; Buffer for partial cluster entry reads (Cluster size)
FReadLock:TMutexHandle; Lock for read buffer
 
FWriteBuffer:Pointer; Buffer for partial cluster entry writes (Cluster size)
FWriteLock:TMutexHandle; Lock for write buffer
 
FClusterBuffer:Pointer; Buffer of exactly cluster size
FClusterLock:TMutexHandle; Lock for cluster buffer
 
function ReadLock:Boolean;  
function ReadUnlock:Boolean;  
 
function WriteLock:Boolean;  
function WriteUnlock:Boolean;  
 
function ClusterLock:Boolean;  
function ClusterUnlock:Boolean;  
 
function LoadTree(AEntry:TDiskEntry):Boolean;  
function MarkTree(AEntry:TDiskEntry):Boolean;  
function PrepareTree(AEntry:TDiskEntry):Boolean;  
function PrepareTable(ATable:TDiskTable):Boolean;  
 
function PrepareTrees:Boolean;  
function CheckCatalogs:Boolean;  
 
function LocatePath(ATable:TCDFSDiskTable; APathNumber:Word):TCDFSDiskPath;  
function LocateEntry(AEntry:TCDFSDiskEntry; AStartCluster:LongWord):TCDFSDiskEntry;  
 
function LoadVolumeFlags:LongWord;  
 
function FillClusters(ACluster:LongWord; ACount:Word; AValue:Byte):Boolean;  
 
function ReadClusters(ACluster:LongWord; ACount:Word; var ABuffer):Boolean;  
function WriteClusters(ACluster:LongWord; ACount:Word; const ABuffer):Boolean;  
 
function TestClusters(ACluster,ACount:LongWord):Boolean;  
function MarkClusters(ACluster,ACount:LongWord; AUsed:Boolean):Boolean;  
 
function AllocClusters(var ACluster:LongWord; ACount:LongWord):Boolean;  
function ReleaseClusters(ACluster,ACount:LongWord):Boolean;  
 
function GetNextFreeCluster:LongWord; Return is a Cluster
function GetFreeClusterCount:LongWord;  
 
function TestBlock(ABlock:TCDFSDiskBlock; AStart,ACount:LongWord):Boolean;  
function MarkBlock(ABlock:TCDFSDiskBlock; AStart,ACount:LongWord; AUsed:Boolean):Boolean;  
 
function AllocBlock(ABlock:TCDFSDiskBlock; AStart,ACount:LongWord):Boolean;  
function ReleaseBlock(ABlock:TCDFSDiskBlock; AStart,ACount:LongWord):Boolean;  
 
function GetBlockNextFree(ABlock:TCDFSDiskBlock; AStart:LongWord):LongWord;  
function GetBlockFreeCount(ABlock:TCDFSDiskBlock):LongWord;  
 
function TestBitmap(ABuffer:Pointer; ASize,AStart,ACount:LongWord):Boolean;  
function MarkBitmap(ABuffer:Pointer; ASize,AStart,ACount:LongWord; AUsed:Boolean):Boolean;  
 
function AllocBitmap(ABuffer:Pointer; ASize:LongWord; AStart,ACount:LongWord):Boolean;  
function ReleaseBitmap(ABuffer:Pointer; ASize:LongWord; AStart,ACount:LongWord):Boolean;  
 
function GetBitmapNextFree(ABuffer:Pointer; ASize,AStart:LongWord):LongWord;  
function GetBitmapFreeCount(ABuffer:Pointer; ASize:LongWord):LongWord;  
 
function GetTableDataFree(ATable:TDiskTable):LongWord;  
function GetEntryDataFree(AEntry:TDiskEntry):LongWord;  
function GetCatalogDataFree(ADescriptor:TCDFSDiskDescriptor):LongWord;  
 
function GetPreviousPath(ATable:TCDFSDiskTable; APath:TCDFSDiskPath):TCDFSDiskPath;  
function GetPreviousEntry(AParent,AEntry:TCDFSDiskEntry):TCDFSDiskEntry;  
 
function GetSectorsPerCluster(AClusterSize:LongWord):LongWord;  
function GetBlockShiftCount(AClusterSize:LongWord):Word;  
function GetSectorShiftCount(AClusterSize:LongWord):Word;  
function GetClusterShiftCount(AClusterSize:LongWord):Word;  
 
function GetEntriesPerBlock(AClusterSize:LongWord):LongWord;  
function GetClustersPerBlock(AClusterSize:LongWord):LongWord;  
function GetTotalBlockCount(ATotalClusterCount:LongWord):LongWord;  
 
function RenumberPaths(ATable:TDiskTable):Boolean;  
 
function ComparePath(APath1,APath2:TCDFSDiskPath; AUnicode:Boolean):Integer;  
function CompareEntry(AEntry1,AEntry2:TCDFSDiskEntry; AUnicode:Boolean):Integer;  
 
function PadString(const AString:String; ALength:Integer; APrefix,AUnicode:Boolean):String;  
function CompareString(const AString1,AString2:String; AReverse:Boolean):Integer;  
 
function ChecksumValidationRecord(AValidation:PELTORITOValidationRecord):Word;  
 
function RecordToPath(ARecord:Pointer; APath:TCDFSDiskPath; AUnicode,AEndian:Boolean):Boolean;  
function PathToRecord(APath:TCDFSDiskPath; ARecord:Pointer; AUnicode,AEndian:Boolean):Boolean;  
 
function RecordToEntry(ARecord:Pointer; AEntry:TCDFSDiskEntry; AUnicode:Boolean):Boolean;  
function EntryToRecord(AEntry:TCDFSDiskEntry; ARecord:Pointer; AUnicode:Boolean):Boolean;  
 
function CDFSTypeToFileSysType(ACDFSType:TCDFSType):TFileSysType;  
protected
function LoadMaxFile:Integer; override;  
function LoadMaxPath:Integer; override;  
function LoadAttributes:LongWord; override;  
function LoadSystemName:String; override;  
function LoadVolumeName:String; override;  
function LoadVolumeSerial:LongWord; override;  
function LoadFileSysType:TFileSysType; override;  
 
function SetVolumeName(const AName:String):Boolean;  
function SetVolumeSerial(ASerial:LongWord):Boolean;  
 
function ReadEntry(AParent,AEntry:TDiskEntry; var ABuffer; const AStart:Int64; ACount:LongWord; var AOffset,AValue:LongWord):Integer; override;  
function WriteEntry(AParent,AEntry:TDiskEntry; const ABuffer; const AStart:Int64; ACount:LongWord; var AOffset,AValue:LongWord):Integer; override;  
 
function LoadTrees:Boolean; Not override
function LoadTables:Boolean; override;  
function LoadBlocks:Boolean; override;  
function LoadDescriptors:Boolean; Not override
function LoadRoots:Boolean; Not override
function LoadPaths(ATable:TCDFSDiskTable):Boolean; Not override
function LoadEntries(AParent:TDiskEntry):Boolean; override;  
function LoadCatalogs:Boolean; override;  
 
function SetPaths(ATable:TCDFSDiskTable):Boolean; Not override
function SetEntries(AParent:TDiskEntry):Boolean; Not override
function SetCatalogs:Boolean; Not override
 
function LoadTable(ATableNo:LongWord):Boolean; override;  
function LoadBlock(ABlockNo:LongWord):Boolean; override;  
function LoadDescriptor(ABuffer:Pointer; ACluster:LongWord):Boolean; Not override
function LoadRoot(ADescriptor:TCDFSDiskDescriptor):Boolean; Not override
function LoadPath(ATable:TCDFSDiskTable; ABuffer:Pointer; AOffset:LongWord; ANumber:Word):Boolean; Not override
function LoadEntry(AParent:TCDFSDiskEntry; ABuffer:Pointer; AOffset,ACluster:LongWord):Boolean; Not override
function LoadHeader(ABuffer:Pointer; AOffset,ACluster:LongWord; AHeaderNo:LongWord):Boolean; Not override
function LoadCatalog(ABuffer:Pointer; AOffset,ACluster:LongWord; ACatalogNo:LongWord; AInitial:Boolean):Boolean; Not override
function LoadExtension(ABuffer:Pointer; AOffset,ACluster:LongWord; AExtensionNo:LongWord):Boolean; Not override
function LoadExtended(AEntry:TDiskEntry):Boolean; Not override
 
function AddDescriptor(AType:Byte):TCDFSDiskDescriptor; Not override
function RemoveDescriptor(ADescriptor:TCDFSDiskDescriptor):Boolean; Not override
 
function AddPath(ATable:TDiskTable; AParentNumber:Word; const AName:String; AStartCluster:LongWord):TCDFSDiskPath; Not override
function RemovePath(ATable:TDiskTable; APath:TCDFSDiskPath):Boolean; Not override
function RenamePath(ATable:TDiskTable; APath:TCDFSDiskPath; const AName:String):Boolean; Not override
function MovePath(ATable:TDiskTable; ADestNumber:Word; APath:TCDFSDiskPath):Boolean; Not override
 
function AddEntry(AParent:TDiskEntry; const AName:String; AAttributes:LongWord; AReference:Boolean):TDiskEntry; override;  
function AddEntryEx(AParent:TDiskEntry; const AName,AAltName:String; AAttributes:LongWord; AReference:Boolean):TDiskEntry; override;  
function RemoveEntry(AParent,AEntry:TDiskEntry):Boolean; override;  
function RenameEntry(AParent,AEntry:TDiskEntry; const AName:String):Boolean; override;  
function RenameEntryEx(AParent,AEntry:TDiskEntry; const AAltName:String):Boolean; override;  
function MoveEntry(ASource,ADest,AEntry:TDiskEntry):Boolean; override;  
 
function AddCatalog(AEntry:TDiskEntry; AMediaType:TMediaType; AFloppyType:TFloppyType; AAttributes:LongWord; ASectorSize:Word; const ASectorCount:Int64):TDiskCatalog; override;  
function RemoveCatalog(ACatalog:TDiskCatalog):Boolean; override;  
function GetNextHeaderNo:LongWord; Not override
function GetMaxHeaderNo:LongWord; Not override
function GetNextHeaderOffset:LongWord; Not override
function GetNextHeaderCluster:LongWord; Not override
function GetNextCatalogOffset:LongWord; Not override
function GetNextCatalogCluster:LongWord; Not override
 
function SetTable(ATable:TDiskTable):Boolean; override;  
function SetBlock(ABlock:TDiskBlock):Boolean; override;  
function SetDescriptor(ADescriptor:TCDFSDiskDescriptor):Boolean; Not override
function SetRoot(ADescriptor:TCDFSDiskDescriptor; ARoot:TDiskEntry):Boolean; Not override
function SetPath(ATable:TDiskTable; APath:TCDFSDiskPath; ABuffer:Pointer):Boolean; Not override
function SetEntry(AParent,AEntry:TDiskEntry):Boolean; override;  
function SetHeader(AHeader:TCDFSDiskHeader):Boolean; Not override
function SetCatalog(ACatalog:TDiskCatalog):Boolean; override;  
function SetExtension(AExtension:TCDFSDiskExtension):Boolean; Not override
function SetExtended(AEntry:TDiskEntry; AExtended:TCDFSDiskExtended):Boolean; Not override
 
function SizeEntry(AParent,AEntry:TDiskEntry; const ASize:Int64):Boolean; override;  
 
function GetBlock(ABlockNo:LongWord):TDiskBlock; override;  
function GetBlockEx(ABlockNo:LongWord; AWrite:Boolean):TDiskBlock; override;  
function GetDescriptor(AType,AInstance:Byte):TCDFSDiskDescriptor; Not override
function GetDescriptorEx(AType,AInstance:Byte; AWrite:Boolean):TCDFSDiskDescriptor; Not override
function GetRoot(ADescriptor:TCDFSDiskDescriptor):TDiskEntry; Not override
function GetPath(ATable:TDiskTable; AParentNumber:Word; const AName:String):TCDFSDiskPath; Not override
function GetHeader(AHeaderNo:LongWord):TCDFSDiskHeader; Not override
function GetHeaderEx(AHeaderNo:LongWord; AWrite:Boolean):TCDFSDiskHeader; Not override
function GetExtension(AExtensionNo:LongWord):TCDFSDiskExtension; Not override
function GetExtensionEx(AExtensionNo:LongWord; AWrite:Boolean):TCDFSDiskExtension; Not override
function GetExtended(AEntry:TDiskEntry):TCDFSDiskExtended; Not override
 
function GetVersion(const AName:String):String;  
 
function StripDot(const AName:String):String;  
function StripVersion(const AName:String):String;  
 
function CompareName(const AName,AMatch:String; AWildcard:Boolean):Boolean; override;  
function CompareSequence(const ASequence; const ACompare; ASize:Integer):Boolean;  
function CompareIdentifier(const AIdentifier; const ACompare; ASize:Integer):Boolean;  
 
function CalculateVolumeSerial(ABuffer:Pointer; ASize:Integer):LongWord;  
public
property ReadOnly:Boolean read FReadOnly write FReadOnly;  
property LongNames:Boolean read FLongNames write FLongNames;  
property CasePreserved:Boolean read FCasePreserved write FCasePreserved;  
property UnicodeNames:Boolean read FUnicodeNames write FUnicodeNames;  
property SwapSerial:Boolean read FSwapSerial write FSwapSerial;  
 
function FileSystemInit:Boolean; override;  
 
function MountFileSystem:Boolean; override;  
function DismountFileSystem:Boolean; override;  
function InitializeFileSystem(ASectorsPerCluster:LongWord; AFileSysType:TFileSysType):Boolean; override;  
 
function GetDriveLabel:String; override;  
function SetDriveLabel(const ALabel:String):Boolean; override;  
function SetDriveSerial(ASerial:LongWord):Boolean; override;  
 
function GetDriveFreeSpaceEx:Int64; override;  
function GetDriveTotalSpaceEx:Int64; override;  
 
function GetDriveInformation(var AClusterSize:LongWord; var ATotalClusterCount,AFreeClusterCount:Int64):Boolean; override;  


Function declarations



constructor TCDFSFileSystem.Create(ADriver:TFileSysDriver; AVolume:TDiskVolume; ADrive:TDiskDrive);
Description: To be documented
Note None documented


destructor TCDFSFileSystem.Destroy;
Description: To be documented
Note None documented


function TCDFSFileSystem.ReadLock:Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.ReadUnlock:Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.WriteLock:Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.WriteUnlock:Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.ClusterLock:Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.ClusterUnlock:Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.LoadTree(AEntry:TDiskEntry):Boolean;
Description: Load all Entries in a given Tree
Note Should only by called by LoadTrees


function TCDFSFileSystem.MarkTree(AEntry:TDiskEntry):Boolean;
Description: To be documented
Note Should only by called by LoadBlocks


function TCDFSFileSystem.PrepareTree(AEntry:TDiskEntry):Boolean;
Description: To be documented
Note Should only by called by PrepareTrees


function TCDFSFileSystem.PrepareTable(ATable:TDiskTable):Boolean;
Description: To be documented
Note Should only by called by PrepareTrees

Caller must hold the tables lock


function TCDFSFileSystem.PrepareTrees:Boolean;
Description: Prepare Trees releases all entries and paths in the Primary Descriptor except Root
Note Releasing the entry or path simply implies setting the bytes on disk to zero

Uses PrepareTree and PrepareTable above
Should only be called by Add/Remove/Rename/MovePath/Entry


function TCDFSFileSystem.CheckCatalogs:Boolean;
Description: Check Catalogs checks all catalogs for a non zero cluster count
Note If any catalogs have zero clusters allocated then LoadBlocks will not present an accurate map of the disk and AllocClusters cannot reliably assign clusters

Should only be called by AllocClusters


function TCDFSFileSystem.LocatePath(ATable:TCDFSDiskTable; APathNumber:Word):TCDFSDiskPath;
Description: To be documented
Note Should only be called by LoadPath, AddPath and MovePath

Caller must hold the tables and paths lock


function TCDFSFileSystem.LocateEntry(AEntry:TCDFSDiskEntry; AStartCluster:LongWord):TCDFSDiskEntry;
Description: To be documented
Note Should only be called by LoadCatalog

Caller must hold the entries lock


function TCDFSFileSystem.LoadVolumeFlags:LongWord;
Description: To be documented
Note None documented


function TCDFSFileSystem.FillClusters(ACluster:LongWord; ACount:Word; AValue:Byte):Boolean;
Description: Fill count clusters with the supplied value
Note None documented


function TCDFSFileSystem.ReadClusters(ACluster:LongWord; ACount:Word; var ABuffer):Boolean;
Description: Read count Clusters from the Volume using Cache
Note Performs conversion of Cluster to Sector based on Offsets

Sector is relative to StartSector of the FileSystem


function TCDFSFileSystem.WriteClusters(ACluster:LongWord; ACount:Word; const ABuffer):Boolean;
Description: Write count Clusters to the Volume using Cache
Note Performs conversion of Cluster to Sector based on Offsets

Sector is relative to StartSector of the FileSystem


function TCDFSFileSystem.TestClusters(ACluster,ACount:LongWord):Boolean;
Description: Test Count clusters from Cluster in the Bitmap Blocks for Free
Note Returns success if Count is zero

The Bitmap is not stored in CDFS and is only used when ReadOnly is False
Should only be called by AllocClusters


function TCDFSFileSystem.MarkClusters(ACluster,ACount:LongWord; AUsed:Boolean):Boolean;
Description: Mark Count clusters from Cluster in the Bitmap Blocks as Free or Used
Note Returns success if Count is zero

The Bitmap is not stored in CDFS and is only used when ReadOnly is False
Should only be called by AllocClusters/ReleaseClusters/LoadBlocks


function TCDFSFileSystem.AllocClusters(var ACluster:LongWord; ACount:LongWord):Boolean;
Description: Allocate Count Clusters from Next Free in the Bitmap Blocks or Allocate the requested Cluster and Count Clusters if available
Note The Bitmap is not stored in CDFS and is only used when ReadOnly is False


function TCDFSFileSystem.ReleaseClusters(ACluster,ACount:LongWord):Boolean;
Description: Release Count Clusters in the Bitmap Blocks and return to Free
Note Returns success if Count is zero

The Bitmap is not stored in CDFS and is only used when ReadOnly is False


function TCDFSFileSystem.GetNextFreeCluster:LongWord;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetFreeClusterCount:LongWord;
Description: To be documented
Note None documented


function TCDFSFileSystem.TestBlock(ABlock:TCDFSDiskBlock; AStart,ACount:LongWord):Boolean;
Description: Test Count clusters from Start in the Block bitmap for Free
Start Start is the cluster number in the block to start from

Start must be greater than or equal to block cluster

Note Should only be called by TestClusters

Caller must hold the blocks lock


function TCDFSFileSystem.MarkBlock(ABlock:TCDFSDiskBlock; AStart,ACount:LongWord; AUsed:Boolean):Boolean;
Description: Mark Count clusters from Start in the Block bitmap as Free or Used
Start Start is the cluster number in the block to start from

Start must be greater than or equal to block cluster

Note Should only be called by MarkClusters

Caller must hold the blocks lock


function TCDFSFileSystem.AllocBlock(ABlock:TCDFSDiskBlock; AStart,ACount:LongWord):Boolean;
Description: To be documented
Note Caller must hold the blocks lock


function TCDFSFileSystem.ReleaseBlock(ABlock:TCDFSDiskBlock; AStart,ACount:LongWord):Boolean;
Description: To be documented
Note Caller must hold the blocks lock


function TCDFSFileSystem.GetBlockNextFree(ABlock:TCDFSDiskBlock; AStart:LongWord):LongWord;
Description: To be documented
Start Start is the cluster number in the block to start from

Start must be greater than or equal to block cluster

Note Should only be called by GetNextFreeCluster

Caller must hold the blocks lock


function TCDFSFileSystem.GetBlockFreeCount(ABlock:TCDFSDiskBlock):LongWord;
Description: To be documented
Note Should only be called by GetFreeClusterCount

Caller must hold the blocks lock


function TCDFSFileSystem.TestBitmap(ABuffer:Pointer; ASize,AStart,ACount:LongWord):Boolean;
Description: Test Count bits from Start in the bitmap for Free
Size Size is the total number of bits in the bitmap
Start Start is the bit number in the bitmap to start from
Count Count is the number of bits in the bitmap to be marked
Note Should only be called by TestBlock

Bitmaps are a multiple of 64 bits in size but free and used blocks are marked using an array of bytes in little endian order
Caller must hold the blocks lock


function TCDFSFileSystem.MarkBitmap(ABuffer:Pointer; ASize,AStart,ACount:LongWord; AUsed:Boolean):Boolean;
Description: Mark Count bits from Start in the bitmap as Free or Used
Size Size is the total number of bits in the bitmap
Start Start is the bit number in the bitmap to start from (0 if first bit)
Count Count is the number of bits in the bitmap to be marked
Note Should only be called by MarkBlock

Bitmaps are a multiple of 64 bits in size but free and used blocks are marked using an array of bytes in little endian order
Caller must hold the blocks lock


function TCDFSFileSystem.AllocBitmap(ABuffer:Pointer; ASize:LongWord; AStart,ACount:LongWord):Boolean;
Description: To be documented
Note Caller must hold the blocks lock


function TCDFSFileSystem.ReleaseBitmap(ABuffer:Pointer; ASize:LongWord; AStart,ACount:LongWord):Boolean;
Description: To be documented
Note Caller must hold the blocks lock


function TCDFSFileSystem.GetBitmapNextFree(ABuffer:Pointer; ASize,AStart:LongWord):LongWord;
Description: To be documented
Size Size is the total number of bits in the bitmap
Start Start is the bit number in the bitmap to start from
Note Should only be called by GetBlockNextFree

Bitmaps are a multiple of 64 bits in size but free and used blocks are marked using an array of bytes in little endian order
Caller must hold the blocks lock


function TCDFSFileSystem.GetBitmapFreeCount(ABuffer:Pointer; ASize:LongWord):LongWord;
Description: To be documented
Size Size is the total number of bits in the bitmap
Note Should only be called by GetBlockFreeCount

Bitmaps are a multiple of 64 bits in size but free and used blocks are marked using an array of bytes in little endian order
Caller must hold the blocks lock


function TCDFSFileSystem.GetTableDataFree(ATable:TDiskTable):LongWord;
Description: To be documented
Note Caller must hold the tables and paths lock


function TCDFSFileSystem.GetEntryDataFree(AEntry:TDiskEntry):LongWord;
Description: To be documented
Note Caller must hold the entries lock


function TCDFSFileSystem.GetCatalogDataFree(ADescriptor:TCDFSDiskDescriptor):LongWord;
Description: To be documented
Note Caller must hold the descriptors, catalogs, headers and extensions lock.


function TCDFSFileSystem.GetPreviousPath(ATable:TCDFSDiskTable; APath:TCDFSDiskPath):TCDFSDiskPath;
Description: To be documented
Note Caller must hold the tables and paths lock


function TCDFSFileSystem.GetPreviousEntry(AParent,AEntry:TCDFSDiskEntry):TCDFSDiskEntry;
Description: To be documented
Note Caller must hold the entries lock


function TCDFSFileSystem.GetSectorsPerCluster(AClusterSize:LongWord):LongWord;
Description: Calculate the number of sectors per cluster
Note Only called during volume mount and initialization


function TCDFSFileSystem.GetBlockShiftCount(AClusterSize:LongWord):Word;
Description: Calculate the block shift count for cluster to block conversion
Note Only called during volume mount and initialization


function TCDFSFileSystem.GetSectorShiftCount(AClusterSize:LongWord):Word;
Description: Calculate the sector shift count for sector to cluster conversion
Note Only called during volume mount and initialization


function TCDFSFileSystem.GetClusterShiftCount(AClusterSize:LongWord):Word;
Description: Calculate the cluster shift count for cluster to bytes conversion
Note Only called during volume mount and initialization


function TCDFSFileSystem.GetEntriesPerBlock(AClusterSize:LongWord):LongWord;
Description: Calculate the number of cluster entries per block of bitmap entries
Note Only called during volume mount and initialization


function TCDFSFileSystem.GetClustersPerBlock(AClusterSize:LongWord):LongWord;
Description: Calculate the number of clusters per block of bitmap entries
Note Only called during volume mount and initialization


function TCDFSFileSystem.GetTotalBlockCount(ATotalClusterCount:LongWord):LongWord;
Description: Calculate the total number of bitmap entry blocks
Note Only called during volume mount and initialization


function TCDFSFileSystem.RenumberPaths(ATable:TDiskTable):Boolean;
Description: To be documented
Note Caller must hold the tables lock


function TCDFSFileSystem.ComparePath(APath1,APath2:TCDFSDiskPath; AUnicode:Boolean):Integer;
Description: To be documented
Note Path Sort Ordering:

- Only Directories are represented
- Root (Dot) is always first
- DotDot for Root is not represented
- Dot and DotDot for other Directories are not represented
- In order of Parent Number (Root Directory is 0001 and Roots ParentNumber is 0001)
- In order of Byte Value in characters of Name with padding of 20 (32) (00 if Unicode)
- In order of Byte Value of characters of Extension with padding of 00 (00) (Only if Unicode)
Caller must hold the paths lock


function TCDFSFileSystem.CompareEntry(AEntry1,AEntry2:TCDFSDiskEntry; AUnicode:Boolean):Integer;
Description: To be documented
Note Entry Sort Ordering:

- Dot is always first
- DotDot is always second
- In order of Byte Value of characters of Name with padding of 20 (32) (00 if Unicode)
- In order of Byte Value of characters of Extension with padding of 20 (32) (00 if Unicode)
- In Reverse order of Byte Value of characters of Version with padding of 30 (48) (00 if Unicode)
Caller must hold the entries lock


function TCDFSFileSystem.PadString(const AString:String; ALength:Integer; APrefix,AUnicode:Boolean):String;
Description: To be documented
Note None documented


function TCDFSFileSystem.CompareString(const AString1,AString2:String; AReverse:Boolean):Integer;
Description: To be documented
Note None documented


function TCDFSFileSystem.ChecksumValidationRecord(AValidation:PELTORITOValidationRecord):Word;
Description: To be documented
Note None documented


function TCDFSFileSystem.RecordToPath(ARecord:Pointer; APath:TCDFSDiskPath; AUnicode,AEndian:Boolean):Boolean;
Description: Loads a Path from a Path record
Note Should only be called by LoadPath

Caller must hold the tables and paths lock


function TCDFSFileSystem.PathToRecord(APath:TCDFSDiskPath; ARecord:Pointer; AUnicode,AEndian:Boolean):Boolean;
Description: Loads a Path record from a Path
Note Should only be called by SetPath

Caller must hold the tables and paths lock


function TCDFSFileSystem.RecordToEntry(ARecord:Pointer; AEntry:TCDFSDiskEntry; AUnicode:Boolean):Boolean;
Description: Loads an Entry from a Directory record
Note Should only be called by LoadEntry and LoadRoot}

{Note: Caller must hold the entries lock


function TCDFSFileSystem.EntryToRecord(AEntry:TCDFSDiskEntry; ARecord:Pointer; AUnicode:Boolean):Boolean;
Description: Loads a Directory record from an Entry
Note Should only be called by SetEntry and SetRoot

Caller must hold the entries lock


function TCDFSFileSystem.CDFSTypeToFileSysType(ACDFSType:TCDFSType):TFileSysType;
Description: To be documented
Note None documented


function TCDFSFileSystem.LoadMaxFile:Integer;
Description: To be documented
Note None documented


function TCDFSFileSystem.LoadMaxPath:Integer;
Description: To be documented
Note None documented


function TCDFSFileSystem.LoadAttributes:LongWord;
Description: To be documented
Note None documented


function TCDFSFileSystem.LoadSystemName:String;
Description: To be documented
Note None documented


function TCDFSFileSystem.LoadVolumeName:String;
Description: To be documented
Note None documented


function TCDFSFileSystem.LoadVolumeSerial:LongWord;
Description: To be documented
Note None documented


function TCDFSFileSystem.LoadFileSysType:TFileSysType;
Description: To be documented
Note None documented


function TCDFSFileSystem.SetVolumeName(const AName:String):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.SetVolumeSerial(ASerial:LongWord):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.ReadEntry(AParent,AEntry:TDiskEntry; var ABuffer; const AStart:Int64; ACount:LongWord; var AOffset,AValue:LongWord):Integer;
Description: Read count bytes from the supplied entry beginning at the supplied start
Note The caller must ensure the entry is large enough or the read will fail

The offset and value parameters are not used by CDFS


function TCDFSFileSystem.WriteEntry(AParent,AEntry:TDiskEntry; const ABuffer; const AStart:Int64; ACount:LongWord; var AOffset,AValue:LongWord):Integer;
Description: Write count bytes to the supplied entry beginning at the supplied start
Note The caller must ensure the entry is large enough or the write will fail

The offset and value parameters are not used by CDFS


function TCDFSFileSystem.LoadTrees:Boolean;
Description: Load all entries in all trees
Note Should only be called by PrepareTrees and LoadBlocks


function TCDFSFileSystem.LoadTables:Boolean;
Description: Load each of the path tables
Note None documented


function TCDFSFileSystem.LoadBlocks:Boolean;
Description: To be documented
Note Should only be called by Alloc/ReleaseClusters and GetNextFreeCluster/GetFreeClusterCount


function TCDFSFileSystem.LoadDescriptors:Boolean;
Description: Load each of the volume descriptors
Note None documented


function TCDFSFileSystem.LoadRoots:Boolean;
Description: To be documented
Note Caller must hold the descriptors lock


function TCDFSFileSystem.LoadPaths(ATable:TCDFSDiskTable):Boolean;
Description: Load the path records of the table as one single block
Note Caller must hold the tables lock


function TCDFSFileSystem.LoadEntries(AParent:TDiskEntry):Boolean;
Description: Load the directory entries of the parent one cluster at a time
Note None documented


function TCDFSFileSystem.LoadCatalogs:Boolean;
Description: To be documented
Note Includes LoadHeaders/LoadExtensions


function TCDFSFileSystem.SetPaths(ATable:TCDFSDiskTable):Boolean;
Description: To be documented
Note Caller must hold the tables lock


function TCDFSFileSystem.SetEntries(AParent:TDiskEntry):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.SetCatalogs:Boolean;
Description: To be documented
Note Includes SetHeaders/SetExtensions


function TCDFSFileSystem.LoadTable(ATableNo:LongWord):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.LoadBlock(ABlockNo:LongWord):Boolean;
Description: To be documented
Note LoadBlock does not populate the Free/Used data in the Bitmap, all bits begin as Free.


function TCDFSFileSystem.LoadDescriptor(ABuffer:Pointer; ACluster:LongWord):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.LoadRoot(ADescriptor:TCDFSDiskDescriptor):Boolean;
Description: Caller must hold the descriptors lock
Note None documented


function TCDFSFileSystem.LoadPath(ATable:TCDFSDiskTable; ABuffer:Pointer; AOffset:LongWord; ANumber:Word):Boolean;
Description: To be documented
Note Caller must hold the tables lock


function TCDFSFileSystem.LoadEntry(AParent:TCDFSDiskEntry; ABuffer:Pointer; AOffset,ACluster:LongWord):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.LoadHeader(ABuffer:Pointer; AOffset,ACluster:LongWord; AHeaderNo:LongWord):Boolean;
Description: To be documented
Note Should only be called by LoadCatalogs


function TCDFSFileSystem.LoadCatalog(ABuffer:Pointer; AOffset,ACluster:LongWord; ACatalogNo:LongWord; AInitial:Boolean):Boolean;
Description: To be documented
Note Should only be called by LoadCatalogs


function TCDFSFileSystem.LoadExtension(ABuffer:Pointer; AOffset,ACluster:LongWord; AExtensionNo:LongWord):Boolean;
Description: To be documented
Note Should only be called by LoadCatalogs


function TCDFSFileSystem.LoadExtended(AEntry:TDiskEntry):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.AddDescriptor(AType:Byte):TCDFSDiskDescriptor;
Description: To be documented
Note None documented


function TCDFSFileSystem.RemoveDescriptor(ADescriptor:TCDFSDiskDescriptor):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.AddPath(ATable:TDiskTable; AParentNumber:Word; const AName:String; AStartCluster:LongWord):TCDFSDiskPath;
Description: To be documented
Note Caller must hold the tables lock


function TCDFSFileSystem.RemovePath(ATable:TDiskTable; APath:TCDFSDiskPath):Boolean;
Description: To be documented
Note Caller must hold the tables lock


function TCDFSFileSystem.RenamePath(ATable:TDiskTable; APath:TCDFSDiskPath; const AName:String):Boolean;
Description: To be documented
Note Caller must hold the tables lock


function TCDFSFileSystem.MovePath(ATable:TDiskTable; ADestNumber:Word; APath:TCDFSDiskPath):Boolean;
Description: To be documented
Note Caller must hold the tables lock


function TCDFSFileSystem.AddEntry(AParent:TDiskEntry; const AName:String; AAttributes:LongWord; AReference:Boolean):TDiskEntry;
Description: To be documented
Reference Add a reference on the returned entry if True


function TCDFSFileSystem.AddEntryEx(AParent:TDiskEntry; const AName,AAltName:String; AAttributes:LongWord; AReference:Boolean):TDiskEntry;
Description: To be documented
Reference Add a reference on the returned entry if True
Note If AltName already exists then a generated one will be provided, will not fail due to AltName.


function TCDFSFileSystem.RemoveEntry(AParent,AEntry:TDiskEntry):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.RenameEntry(AParent,AEntry:TDiskEntry; const AName:String):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.RenameEntryEx(AParent,AEntry:TDiskEntry; const AAltName:String):Boolean; 
Description: To be documented
Note None documented


function TCDFSFileSystem.MoveEntry(ASource,ADest,AEntry:TDiskEntry):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.AddCatalog(AEntry:TDiskEntry; AMediaType:TMediaType; AFloppyType:TFloppyType; AAttributes:LongWord; ASectorSize:Word; const ASectorCount:Int64):TDiskCatalog;
Description: To be documented
Note None documented


function TCDFSFileSystem.RemoveCatalog(ACatalog:TDiskCatalog):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetNextHeaderNo:LongWord;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetMaxHeaderNo:LongWord;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetNextHeaderOffset:LongWord;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetNextHeaderCluster:LongWord;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetNextCatalogOffset:LongWord;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetNextCatalogCluster:LongWord;
Description: To be documented
Note None documented


function TCDFSFileSystem.SetTable(ATable:TDiskTable):Boolean;
Description: To be documented
Note SetTable does not perform any disk writes


function TCDFSFileSystem.SetBlock(ABlock:TDiskBlock):Boolean;
Description: To be documented
Note SetBlock does not perform any disk writes (Blocks are not stored in filesystem)


function TCDFSFileSystem.SetDescriptor(ADescriptor:TCDFSDiskDescriptor):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.SetRoot(ADescriptor:TCDFSDiskDescriptor; ARoot:TDiskEntry):Boolean;
Description: To be documented
Note Caller must hold the descriptors lock


function TCDFSFileSystem.SetPath(ATable:TDiskTable; APath:TCDFSDiskPath; ABuffer:Pointer):Boolean;
Description: To be documented
Note SetPath does not use BlockWrite as Buffer is passed by caller

Caller must hold the tables lock


function TCDFSFileSystem.SetEntry(AParent,AEntry:TDiskEntry):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.SetHeader(AHeader:TCDFSDiskHeader):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.SetCatalog(ACatalog:TDiskCatalog):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.SetExtension(AExtension:TCDFSDiskExtension):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.SetExtended(AEntry:TDiskEntry; AExtended:TCDFSDiskExtended):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.SizeEntry(AParent,AEntry:TDiskEntry; const ASize:Int64):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetBlock(ABlockNo:LongWord):TDiskBlock;
Description: To be documented
Note Overidden to implement multiple entry blocks


function TCDFSFileSystem.GetBlockEx(ABlockNo:LongWord; AWrite:Boolean):TDiskBlock;
Description: To be documented
Note Overidden to implement multiple entry blocks


function TCDFSFileSystem.GetDescriptor(AType,AInstance:Byte):TCDFSDiskDescriptor;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetDescriptorEx(AType,AInstance:Byte; AWrite:Boolean):TCDFSDiskDescriptor;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetRoot(ADescriptor:TCDFSDiskDescriptor):TDiskEntry;
Description: To be documented
Note Caller must hold the descriptors lock


function TCDFSFileSystem.GetPath(ATable:TDiskTable; AParentNumber:Word; const AName:String):TCDFSDiskPath;
Description: To be documented
Note Caller must hold the tables lock


function TCDFSFileSystem.GetHeader(AHeaderNo:LongWord):TCDFSDiskHeader;
Description: To be documented
Note HeaderNo is one based


function TCDFSFileSystem.GetHeaderEx(AHeaderNo:LongWord; AWrite:Boolean):TCDFSDiskHeader;
Description: To be documented
Note HeaderNo is one based


function TCDFSFileSystem.GetExtension(AExtensionNo:LongWord):TCDFSDiskExtension;
Description: To be documented
Note ExtensionNo is one based


function TCDFSFileSystem.GetExtensionEx(AExtensionNo:LongWord; AWrite:Boolean):TCDFSDiskExtension;
Description: To be documented
Note ExtensionNo is one based


function TCDFSFileSystem.GetExtended(AEntry:TDiskEntry):TCDFSDiskExtended;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetVersion(const AName:String):String;
Description: To be documented
Note None documented


function TCDFSFileSystem.StripDot(const AName:String):String;
Description: To be documented
Note None documented


function TCDFSFileSystem.StripVersion(const AName:String):String;
Description: To be documented
Note None documented


function TCDFSFileSystem.CompareName(const AName,AMatch:String; AWildcard:Boolean):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.CompareSequence(const ASequence; const ACompare; ASize:Integer):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.CompareIdentifier(const AIdentifier; const ACompare; ASize:Integer):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.CalculateVolumeSerial(ABuffer:Pointer; ASize:Integer):LongWord;
Description: To be documented
Note None documented


function TCDFSFileSystem.FileSystemInit:Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.MountFileSystem:Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.DismountFileSystem:Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.InitializeFileSystem(ASectorsPerCluster:LongWord; AFileSysType:TFileSysType):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetDriveLabel:String;
Description: To be documented
Note None documented


function TCDFSFileSystem.SetDriveLabel(const ALabel:String):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.SetDriveSerial(ASerial:LongWord):Boolean;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetDriveFreeSpaceEx:Int64;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetDriveTotalSpaceEx:Int64;
Description: To be documented
Note None documented


function TCDFSFileSystem.GetDriveInformation(var AClusterSize:LongWord; var ATotalClusterCount,AFreeClusterCount:Int64):Boolean;
Description: Get Drive Information from internal CDFS data
Note None documented


Return to Unit Reference