No subject


Tue Jun 11 14:29:31 CEST 2019


FUNCTION ClusterSize(Drv:LONGINT):LONGINT;

TYPE FreeRecord=RECORD
                  SizRec        : WORD; { Size of this record}
                  StrucVersion  : WORD; { Structure version}
                  SecPerClus    : CARDINAL;
                  BytePerSec    : CARDINAL;
                  AvailClus     : CARDINAL;
                  TotClus       : CARDINAL;
                  PhysSectAvail : CARDINAL;
                  PhysSectTot   : CARDINAL;
                  AllocAvail    : CARDINAL;
                  AllocTot      : CARDINAL;
                  Res1,
                  Res2          : CARDINAL;
                 END;

CONST SecBuf=20;

VAR R : Registers;
    O : LONGINT;
    S : ARRAY[0..5] OF CHAR;
    S2 : String;
    ClusRec : FreeRecord;

BEGIN
 IF LfnSupport THEN
  BEGIN
    IF Drv=0 THEN
     BEGIN
      GetDir(Drv,S2);
      Drv:=ORD(S2[1])-64;
     END;

    S:='C:\'#0;
    S[0]:=CHR(Drv+64);
    CopyToDos(S,8);
    R.AX:=$7303;
    R.CX:=SIZEOF(FreeRecord);
    R.esi:=tb_offset;
    R.ds:=tb_segment;
    R.edi:=tb_offset+SecBuf;
    R.es:=tb_segment;
    MsDos(R);
    seg_move(dosmemselector,transfer_buffer+SecBuf,get_ds,longint(@ClusRec),SIZEOF(FreeRecord));
    O:=ClusRec.BytePerSec*ClusRec.SecPerClus;
    if (R.flags and carryflag) <> 0 then
     doserror:=R.ax
   else
     doserror:=0;

  END
  ELSE
   BEGIN
    R.AX:=$3600;
    R.DX:=Drv;
    MsDos(R);
    IF R.AX=$FFFF THEN
     O:=0
    ELSE
     O:=R.AX
   END;
  IF IsCdRom(Drv) THEN         {Exception, cdroms are always 2048 
anyway}
   O:=2048;
  ClusterSize:=O;
END;


Marco van de Voort (MarcoV at Stack.nl or marco at freepascal.org)






More information about the fpc-pascal mailing list