FAT12 File Find problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

FAT12 File Find problem

Post 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
Gizmic OS
Currently - Busy with FAT12 driver and VFS
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Re: FAT12 File Find problem

Post 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.
The man who follows the crowd will usually get no further than the crowd.
The man who walks alone is likely to find himself in places
no one has ever been before.
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

Re: FAT12 File Find problem

Post 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
Gizmic OS
Currently - Busy with FAT12 driver and VFS
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: FAT12 File Find problem

Post by Dex »

You keep saying 32bit entrys, do you not mean 32byte entrys ?.
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

Re: FAT12 File Find problem

Post 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.
Gizmic OS
Currently - Busy with FAT12 driver and VFS
Post Reply