home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / pascal / 6391 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.8 KB  |  65 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!mcsun!news.funet.fi!uwasa.fi!ts
  3. From: ts@uwasa.fi (Timo Salmi)
  4. Subject: Is it a directory (in Turbo Pascal)
  5. Message-ID: <1992Nov7.131109.29456@uwasa.fi>
  6. Organization: University of Vaasa, Finland
  7. Date: Sat, 7 Nov 1992 13:11:09 GMT
  8. Lines: 55
  9.  
  10. This is in particular to Richard Breuer (whose email bounces) but
  11. also to the other users.
  12.  
  13. Ricki, I have been looking at your problem of establishing whether a
  14. directory exists or not.  Try if this works on your DrDos 6.0
  15. environment.
  16.  
  17. (* This function returns whether a name is a directory or not.
  18.    Avoid using this on an open file or standard devices.
  19.    By Prof. Timo Salmi, University of Vaasa, Finland *)
  20. function ISDIRFN (name : string) : boolean;
  21. var stash  : byte;
  22.     flep   : file;
  23. begin
  24.   stash := FileMode;
  25.   FileMode := 0;
  26.   assign (flep, name);
  27.   {$I-} reset (flep); {$I+}
  28.   if IOResult = 0 then
  29.     begin
  30.       {$I-} close (flep); {$I+}
  31.       isdirfn := false;
  32.     end
  33.   else
  34.     begin
  35.       assign (flep, name+'NUL');
  36.       {$I-} reset (flep); {$I+}
  37.       if IOResult = 0 then
  38.         begin
  39.           {$I-} close (flep); {$I+}
  40.           isdirfn := true;
  41.         end
  42.       else
  43.         begin
  44.           assign (flep, name+'\NUL');
  45.           {$I-} reset (flep); {$I+}
  46.           if IOResult = 0 then
  47.             begin
  48.               {$I-} close (flep); {$I+}
  49.               isdirfn := true;
  50.             end
  51.           else
  52.             isdirfn := false;
  53.         end;
  54.     end;
  55.   FileMode := stash;
  56. end;  (* isdirfn *)
  57.  
  58.    All the best, Timo
  59.  
  60. ..................................................................
  61. Prof. Timo Salmi
  62. Moderating at garbo.uwasa.fi anonymous FTP archives 128.214.87.1
  63. Faculty of Accounting & Industrial Management; University of Vaasa
  64. Internet: ts@uwasa.fi Bitnet: salmi@finfun   ; SF-65101, Finland
  65.