FAT12 File Find problem
Posted: Sat Dec 27, 2008 10:13 am
I have my Floppy Driver working and I have set up a read for the Boot Information. This all work fine. I am now trying to implement File finding, but I have run into a problem The code I created to scan through the root dir in 32bit pieces should work but nothing ever is in it. I know the problem is not my Move function as I use it for the Disk Info Function. Am I missing something special that must be done to read the Root Dir.
- I know root Dir entries are 32bits
- I know there are 16 of them per sector
- I know the root dir starts on sector 19
- I know that the root dir is 14 sectors long
Here is my finding code.
Any advice will help
- I know root Dir entries are 32bits
- I know there are 16 of them per sector
- I know the root dir starts on sector 19
- I know that the root dir is 14 sectors long
Here is my finding code.
Code: Select all
TDirectory = packed record
Filename : array[1..8] of char;
Extention : array[1..3] of char;
Attrib : Byte;
Reserved : Word;
CreationTime : Word;
CreationDate : Word;
LastAccessD : Word;
Ignore : Word;
LastWriteT : Word;
LastWriteD : Word;
StartCluster : Word;
FileSize : array[1..4] of byte;
end;
TRoot = array[0..224] of TDirectory;
function FindFile(FName : string) : word;
var
k, l : integer;
Found : boolean = false;
begin
//14 sectors
FloppyRead(0, 19, true, 14);
Move(Buffer,DirSec,(SizeOf(DirSec)));
ClearScreen;
GoToXY(0,1);
for k := 1 to 224 do
begin
Found := True;
l := 0;
while (Found = True) and (l <= Length(FName)) do
begin
Inc(l);
if DirSec[k].Filename[l] <> FName[l] then
Found := False;
end;
if Found = True then
begin
PrintString(#10'File ' + FName + 'Found in Sector: ' + IntToStr((k div 16)+1) + ' Entry: ' );
Exit;
end;
end;