home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / lilith / m2del.mod < prev    next >
Text File  |  2020-01-01  |  2KB  |  84 lines

  1. IMPLEMENTATION MODULE KermDel;
  2. (************************************************************************)
  3. (* Deletes one or more files from disk                                  *)
  4. (* written:            11.12.85     Matthias Aebi                       *)
  5. (* last modification:  18.03.86     Matthias Aebi                       *)
  6. (************************************************************************)
  7.  
  8. FROM FileSystem  IMPORT Lookup, Close, Rename, File;
  9. FROM Terminal    IMPORT WriteString, Write, WriteLn, Read;
  10. FROM OutTerminal IMPORT WriteC;
  11. FROM String      IMPORT Insert;
  12. FROM NameSearch  IMPORT FindNames, NextName;
  13. FROM M2Kermit    IMPORT Param1;
  14.  
  15. CONST
  16.     UpLowEqual = TRUE;
  17.  
  18. (************************************************************************)
  19.                               PROCEDURE Delete;
  20. (************************************************************************)
  21. VAR
  22.     fileName   : ARRAY [0..20] OF CHAR;
  23.     answer     : CHAR;
  24.     theFile    : File;
  25.     foundOne   : BOOLEAN;
  26.     noFile     : BOOLEAN;
  27.     fileNo     : CARDINAL;
  28.     versionNo  : CARDINAL;
  29.     counter    : CARDINAL;
  30.  
  31.  
  32. BEGIN
  33.     IF Param1[0] = "?"
  34.     THEN
  35.         WriteString("Specify file to delete (including wildcards)");
  36.     ELSE
  37.         counter := 0;
  38.         noFile := TRUE;
  39.         FindNames("DK", Param1, UpLowEqual);
  40.  
  41.         REPEAT
  42.             NextName(foundOne, fileName, fileNo, versionNo);
  43.             IF foundOne
  44.             THEN
  45.                 WriteLn;
  46.                 noFile := FALSE;
  47.                 Insert(fileName, 0, "DK."); (* add device name *)
  48.  
  49.                 WriteString("Do you want to delete the file ");
  50.                 WriteString(fileName);
  51.                 WriteString(" (y/n) ? ");
  52.                 answer := "X";
  53.                 Read(answer);
  54.  
  55.                 IF CAP(answer) = "Y"
  56.                 THEN
  57.                     WriteString("yes");
  58.                     Lookup(theFile, fileName, FALSE);
  59.                     Rename(theFile,"DK.");
  60.                     Close(theFile);
  61.                     INC(counter);
  62.                 ELSE
  63.                     WriteString("no");
  64.                 END;
  65.             END;
  66.         UNTIL NOT foundOne;
  67.  
  68.         WriteLn;
  69.  
  70.         IF noFile
  71.         THEN
  72.             WriteString("File not found");
  73.         ELSE
  74.             WriteC(counter,3);
  75.             WriteString(" file(s) deleted");
  76.         END;
  77.         WriteLn;
  78.  
  79.     END;
  80.  
  81. END Delete;
  82.  
  83. END KermDel.
  84.