Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!snorkelwacker.mit.edu!ira.uka.de!smurf!artcom0!hb.maus.de!ms.maus.de!Kai_Henningsen From: Kai_Henningsen@ms.maus.de (Kai Henningsen) Newsgroups: comp.lang.pascal Subject: Re: how can I readout my FAT? Message-ID: <14186@ms.maus.de> Date: 27 Apr 91 11:52:00 GMT Distribution: world,comp Organization: Maus Mailbox Netz - UUCP-Gateway Bremen Lines: 164 Stefan Focke focke @ gmdzi.gmd.de schrieb am 22.04.1991, 08:33 SF>Hello, SF> SF>it is not too hard to do that: SF> SF>- Read the boot-sektor to find out where your directory and FAT is SF>- From the directory you get the first cluster of your file SF>- Than you have to follow the FAT to find all clusters of your file SF>- You have to find out if you have a 12-bit or a 16-Bit FAT (DOS 4.x) SF> I do not know where you can find this information. Who can help? Well, looks like it's time to post a program I wrote. The purpose is to set the date of every directory on a disk to that of the youngest file within. Be warned that, while the program runs without a problem on *my* harddisk (DOS 4), I do not make any claims that the same will be true elsewhere - the risk is yours, completely; I wrote this only for myself. You better make a backup first!! Also, the code is for TP 6.0, I use the inline assembler. As for comments, well ... Pascal is supposed to be selfdocumenting, no? But ask me if you don't understand something ... So, first a support unit ... unit DosAbsUt; interface uses Dos; type BootRec = record jmp: array[1..3] of byte; OEM: array[1..8] of char; bps: word; spc: byte; res: word; nFAT: byte; RootSz: word; Size: word; Media: byte; spFAT: word; spt: word; nHeads: word; res40: longint; Size40: longint; Phys: byte; nix: byte; Sig: byte; { $29 } ID: longint; Volume: array [1..11] of char; nix2: array[1..8] of char; end; function AbsRead(Drive: byte; nSecs: word; Start: longint; var Buffer): word; function AbsWrite(Drive: byte; nSecs: word; Start: longint; var Buffer): word; function SecSize(Drive: byte): word; procedure ResetDisk; implementation var r: registers; Dos4Abs : record First: longint; Count: word; Buf: pointer; end; function AbsRead(Drive: byte; nSecs: word; Start: longint; var Buffer): word; begin if lo(dosversion)<4 then begin asm {[f-]} mov al, [Drive]; mov cx, [nSecs]; mov dx, word ptr [Start]; push ds; lds bx, [Buffer]; int $25; jc @Err; xor ax, ax; @Err: popf; pop ds; mov [@Result], ax end {[f+]}; end else begin with Dos4Abs do begin First:=Start; Count:=nSecs; Buf:=@Buffer; end; asm {[f-]} mov al, [Drive]; mov cx, -1; push ds; mov bx, seg Dos4Abs; mov ds, bx; mov bx, offset Dos4Abs; int $25; jc @Err; xor ax, ax; @Err: popf; pop ds; mov [@Result], ax end {[f+]}; end; end; function AbsWrite(Drive: byte; nSecs: word; Start: longint; var Buffer): word; begin if lo(dosversion)<4 then begin asm {[f-]} mov al, [Drive]; mov cx, [nSecs]; mov dx, word ptr [Start]; push ds; lds bx, [Buffer]; int $26; jc @Err; xor ax, ax; @Err: popf; pop ds; mov [@Result], ax end {[f+]}; end else begin with Dos4Abs do begin First:=Start; Count:=nSecs; Buf:=@Buffer; end; asm {[f-]} mov al, [Drive]; mov cx, -1; push ds; mov bx, seg Dos4Abs; mov ds, bx; mov bx, offset Dos4Abs; int $26; jc @Err; xor ax, ax; @Err: popf; pop ds; mov [@Result], ax end {[f+]}; end; end; function SecSize(Drive: byte): word; begin with r do begin ah:=$1c; dl:=drive+1; msdos(r); secsize:=cx; end; end; procedure ResetDisk; begin r.ah:=$0d; msdos(r); end; end. MfG Kai