home *** CD-ROM | disk | FTP | other *** search
/ PC Open 19 / pcopen19.iso / Zipped / CALMIR21.ZIP / SOURCE.ZIP / SRC / DIREXIST.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-02-20  |  657 b   |  31 lines

  1. program DirExist;
  2.  
  3. { Note : this program is for MS-DOS Turbo Pascal, not Delphi }
  4.  
  5. uses WinDOS, Strings;
  6.  
  7. function IsRoot(s: string): Boolean;
  8. begin
  9.   s[1] := UpCase(s[1]);
  10.   IsRoot := (Length(s) = 3) and (s[1] >= 'A') and (s[1] <= 'Z')
  11.     and (s[2] = ':') and (s[3] = '\');
  12. end;
  13.  
  14. var
  15.   buf : array[0..255] of Char;
  16.   filename: string;
  17.   SR : TSearchRec;
  18.   Code : Word;
  19. begin
  20.   filename := ParamStr(1);
  21.   if filename = '' then Halt(0);
  22.  
  23.   if IsRoot(filename) then Halt(1);
  24.  
  25.   FindFirst(StrPCopy(buf, filename), faDirectory, SR);
  26.   if (DosError = 0) and (SR.Attr and faDirectory <> 0) then
  27.     Halt(1)
  28.   else
  29.     Halt(0);
  30.  
  31. end.