home *** CD-ROM | disk | FTP | other *** search
- Function ClusterNumber: word;
- type
- FnameType = array[0..7] of Char;
- FextType = array[0..2] of Char;
-
- DTArec =
- record
- DOSnext : array[1..21] of Byte;
- attr : Byte;
- fTime, fDate, flSize, fhSize : Integer;
- FullName : array[1..13] of Char;
- end;
-
- UnopenedFCBrec =
- record
- flag : Byte;
- junk : array[0..4] of Byte;
- SearchAttr : Byte;
- drive : Byte;
- fName : FnameType;
- fExt : FextType;
- attr : Byte;
- DOSnext : array[12..21] of Byte;
- fTime, fDate, fCluster, flSize, fhSize : word;
- end;
-
- var
- FCB : UnopenedFCBrec;
- dta : DTArec;
- FCBreturn : UnopenedFCBrec absolute dta;
- reg : registers;
- SearName: string;
- SearExt : string;
- DriveNumber:byte;
- place :byte;
-
- procedure SetDTA(var dta : DTArec);
- begin
- reg.ah := $1A;
- reg.ds := Seg(dta);
- reg.dx := Ofs(dta);
- MsDos(reg);
- end;
-
- procedure InitFCB(var FCB : UnopenedFCBrec; driveNum : Byte;
- name, ext : String; sattr : Byte);
- begin
- FillChar(FCB, SizeOf(FCB), 32);
- with FCB do begin
- flag := $FF;
- SearchAttr := sattr;
- drive := driveNum;
- Move(name[1], fName, Length(name));
- if Length(ext) > 0 then
- Move(ext[1], fExt, Length(ext));
- end;
- end;
-
- begin
- DriveNumber:=Ord(Upcase(DriveLetter))-64;
- getdir(DriveNumber,SearName);
- SearName := JustFileName(SearName);
- SearExt := JustExtension(SearName);
- Place:=Pos('.',SearName);
- If Place > 0 then
- Delete(Searname,Place,Length(SearName));
- {$I-}
- Chdir(DriveLetter+':');
- If IOResult<>0 then Writeln('Error setting drive ',IoResult);
- Chdir('..');
- {$I+}
- If IOResult=0 then
- SearchMode := Cluster
- else
- begin
- SearchMode := Root;
- ClusterNumber:= RootBegin;
- exit;
- end;
- SetDTA(dta);
- { drive C, some dir, dir attr}
- InitFCB(FCB, DriveNumber, SearName,SearExt, $10);
- FillChar(FCBreturn, SizeOf(FCBreturn), 0);
- reg.ah := $11;
- reg.ds := Seg(FCB);
- reg.dx := Ofs(FCB);
- MsDos(reg);
- {$I-}
- chdir(SearName+'.'+SearExt);
- {$I+}
- If IOResult<>0 then Writeln('Error setting dir ',IoResult);
- if reg.al = $FF then WriteLn('Error in XFCB ');
- ClusterNumber:=FCBreturn.fCluster;
- end; { function ClusterNumber }