Page 1 of 1

FAT12 File Find problem

Posted: Sat Dec 27, 2008 10:13 am
by System123
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.

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;


Any advice will help

Re: FAT12 File Find problem

Posted: Sat Dec 27, 2008 10:27 am
by xyjamepa
Hi,

you should put in mind that the files names on the disk are written in capital letters,
for example: MYFILE TXT,
Also the file name is limited to 8 chars and the extension is limited to 3 chars,
and when the file name is shorter than 8 chars the rest chars will be 0x20 (blank),like
in the example above.
hope this help.

Re: FAT12 File Find problem

Posted: Sat Dec 27, 2008 11:07 am
by System123
I have put that in mind I made sure everything matched. The problem is nothing ever seems to be copied into my Dir Entry it is alway blank 0x00

Re: FAT12 File Find problem

Posted: Sat Dec 27, 2008 12:12 pm
by Dex
You keep saying 32bit entrys, do you not mean 32byte entrys ?.

Re: FAT12 File Find problem

Posted: Sat Dec 27, 2008 10:28 pm
by System123
Sorry, yes I did mean 32byte. My entry is that big anyway. I think I might of solved the problem. My buffer was faulty.