home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
pascal
/
vdl020d.zip
/
CLUSTLIB.DOC
< prev
next >
Wrap
Text File
|
1993-04-14
|
6KB
|
196 lines
{$R-,S-,V-,I-,A-,D+}
Unit ClustLib;
{-------------------------------------------------------------------------}
{ Unit ClustLib }
{-------------------------------------------------------------------------}
{ PURPOSE: Provides basic DOS disk access as well as file operations. }
{ SOURCE: Steve Lewis }
{-------------------------------------------------------------------------}
USES
VCrt,
VGen,
VCDPLIB,
VSDLPLow,
VWinlow,
VWinhigh;
TYPE
BPBType = RECORD
BytesPerSector : WORD;
SectorsPerCluster : BYTE;
Reserved : WORD;
FATs : BYTE;
RootDirEntries : WORD;
Sectors : WORD;
MediaDescriptors : BYTE;
SectorsPerFAT : WORD;
SectorsPerTrack : WORD;
Heads : WORD;
Hidden : LONGINT;
BigTotalSectors : LONGINT;
END;
FDiskTypePtr = ^FDiskType;
ExtraFDiskInfo = RECORD
Case BYTE of
5 : ( RealID : BYTE;
StartBlock : LONGINT;
NumBlocks : LONGINT;
Offset : LONGINT;
NextPar : FDiskTypePtr );
1,2,4,6,92,99,100 : ( Reserved : ARRAY[1..17] of BYTE )
END;
FDiskType = RECORD
BootBlock : LONGINT;
NumBlocks : LONGINT;
Offset : LONGINT;
Active : BYTE;
BPB : BPBType;
ID : BYTE;
B : ExtraFDiskInfo;
WhichOne : BYTE;
END;
SDLPParType = RECORD
StartBlock : LONGINT;
NumFDisks : BYTE;
FDisks : ARRAY[1..4] of FDiskType;
END;
SDLPParTypeArray = ARRAY[1..1] of SDLPParType;
MainParType = RECORD
UnitNum : BYTE;
NumDOSPars : BYTE;
SDLP : BOOLEAN;
DOSPars : ^SDLPParTypeArray;
END;
{---------------------------}
DirEntryType = RECORD
Name : ARRAY[0..10] of CHAR;
Attr : BYTE;
Reserved : ARRAY[0..9] of BYTE;
Time : WORD;
Date : WORD;
StartCluster : WORD;
Size : LONGINT;
END;
DirEntryArray = ARRAY[0..511] of DirEntryType;
{--------------------------------------------------------------}
{ The two fat types are for 12 and 16-Bit FATs, respectively. }
{ The 16-bit FAT canbe 128K, thus I have made a structure that }
{ is 32K and have an array of [1..4] of it. The 12-Bit FAT }
{ can only ever be 40K or so, thus I have made 56K for ease. }
{--------------------------------------------------------------}
FATType16 = ARRAY[0..16383] of WORD;
FatType12 = ARRAY[0..57343] of BYTE;
SearchType = RECORD
Name : STRING[12];
Attr : BYTE;
Size : LONGINT;
END;
{---------------------------}
Procedure ReadFDiskBootSector( ParUnitNum : BYTE;
First : BOOLEAN;
var FDisk : FDiskType );
Procedure ReadFDiskSectors( ParUnitNum : BYTE;
ParNum : BYTE;
SDLPParNum : BYTE );
Procedure ReadSDLPBootSector( UnitNum : BYTE );
Procedure DisposeDOSPars;
Procedure ScanSystem;
Procedure LoadFatTable( LocalUnitNum : BYTE;
BPB : BPBType;
BootBlock : LONGINT );
Procedure LoadDirTable( ClusterNum : LONGINT );
Procedure FindNext( var Search : SearchType );
Procedure FindFirst( var Search : SearchType );
Procedure ChangeDir( S : STRING );
{---------------------------}
VAR
Pars : ARRAY[0..63] of MainParType;
NumPars : BYTE;
UnitNum : BYTE;
ClusterSize : LONGINT;
FatSize : WORD;
FatSector : LONGINT;
FatBits : BYTE;
RootSector : LONGINT;
DirCluster : LONGINT;
NextDirCluster : LONGINT;
DataSector : LONGINT;
FAT16 : ARRAY[1..4] of ^FATType16;
FAT12 : ^FATType12;
LastRootEntry : WORD;
LastEntry : WORD;
RealEntry : WORD;
IsRootLoaded : BOOLEAN;
RootDir : ^DirEntryArray;
DirData : ^DirEntryArray;
NewDosError : INTEGER;
ClustLibLoopy : BYTE;
{------------------------------------------------}
{ This is a copy of the FDisk 16-byte structure: }
{ }
{ Active == 1 BYTE }
{ 128 means Active, 0 means Non-Active }
{ }
{ BeginHead == 1 BYTE }
{ }
{ BeginSector == 1 BYTE }
{ }
{ BeginCylinder == 1 BYTE }
{ }
{ FDisk ID == 1 BYTE }
{ 1 is a DOS 12-Bit FAT }
{ 2 is a XENIX partition }
{ 4 is a DOS 16-Bit FAT }
{ 5 is a DOS Extended partition }
{ 6 is a DOS Bootable > 32 MB partition }
{ 86 ???? }
{ 92 SDPS FDisk partition }
{ 99 Unix partition }
{ 100 Unused partition }
{ }
{ EndingHead == 1 BYTE }
{ }
{ EndingSector == 1 BYTE }
{ }
{ EndingCylinder == 1 BYTE }
{ }
{ StartSector == 4 BYTEs }
{ }
{ NumberOfSectors == 4 BYTEs }
{------------------------------------------------}