home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / OB3.2D4.DMS / in.adf / Beispiele / Files.mod < prev    next >
Encoding:
Text File  |  1992-10-10  |  1.7 KB  |  70 lines

  1. MODULE Files;
  2.  
  3. IMPORT Dos, Utility, Exec, OberonLib;
  4.  
  5. VAR
  6.   buffer: Dos.ExAllDataPtr;
  7.   control: Dos.ExAllControlPtr;
  8.   more: BOOLEAN;
  9.   data: Dos.ExAllDataPtr;
  10.   ln: BOOLEAN;
  11.   cd: Dos.FileLockPtr;
  12.  
  13. CONST
  14.   bufsize = 2048;
  15.  
  16.   PROCEDURE MatchFunk(hook: Utility.HookPtr;
  17.                       type: Exec.APTR;
  18.                       match: Exec.APTR): LONGINT;
  19.  
  20.   VAR
  21.     m: Dos.ExAllDataPtr;
  22.  
  23.   BEGIN
  24.     m := match;
  25.     IF m.type = Dos.file THEN RETURN -1
  26.                          ELSE RETURN  0 END;
  27.   END MatchFunk;
  28.  
  29.  
  30. BEGIN
  31.   IF Dos.dos.lib.version>=37 THEN
  32.     IF ~ OberonLib.wbStarted THEN
  33.       control := Dos.AllocDosObjectTags(Dos.exAllControl);
  34.       IF control=NIL THEN
  35.         Dos.PrintF("AllocDosObject failed!\n");
  36.       ELSE
  37.         control.lastKey := 0;
  38.         NEW(control.matchFunc);
  39.         Utility.InitHook(control.matchFunc,MatchFunk);
  40.         OberonLib.New(buffer,bufsize);
  41.         ln := FALSE;
  42.         cd := Dos.Lock("",Dos.sharedLock);
  43.         IF cd=NIL THEN
  44.           Dos.PrintF("Lock failed!\n");
  45.         ELSE
  46.           REPEAT
  47.             more := Dos.ExAll(cd,buffer^,bufsize,Dos.size,control);
  48.             IF ~more & (Dos.IoErr()#Dos.noMoreEntries) THEN
  49.               Dos.PrintF("Fehler!\n");
  50.             ELSE
  51.               IF control.entries>0 THEN
  52.                 data := buffer;
  53.                 REPEAT
  54.                   Dos.PrintF("%-24s %8ld    ",data.name,data.size);
  55.                   IF ln THEN Dos.PrintF("\n") END;
  56.                   ln := ~ln;
  57.                   data := data.next;
  58.                 UNTIL data=NIL;
  59.               END;
  60.             END;
  61.           UNTIL ~more;
  62.           IF ln THEN Dos.PrintF("\n") END;
  63.           Dos.UnLock(cd);
  64.         END;
  65.         Dos.FreeDosObject(Dos.exAllControl,control);
  66.       END;
  67.     END;
  68.   END;
  69. END Files.
  70.