home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / dm.lzh / multidel.c < prev    next >
Text File  |  1995-04-07  |  4KB  |  123 lines

  1. /* multidel.c function for DISKMASTER.C       */
  2. /* copyright (c) 1995 by Bob Devries          */
  3. /* email: bdevries@gil.ipswichcity.qld.gov.au */
  4.  
  5. /* deletes multiple files from current directory */
  6.  
  7. #include "diskmaster.h"
  8. #include <stdio.h>
  9. #include <strings.h>
  10. #include <modes.h>
  11.  
  12. multidel(numfiles)
  13. int numfiles;
  14. {
  15.     extern char **nameptr;
  16.     extern short *attrptr;
  17.     int x, confirm, ask;
  18.     char *delcmd, *malloc();
  19.  
  20.     delcmd = malloc(numfiles*32+256);
  21.  
  22.     gotoxy(1,24);
  23.     cleol();
  24.     printf("     %cConfirm each delete? (y/N) ",7);
  25.     do {
  26.         confirm = toupper(getchar());
  27.         flush_kbd();
  28.     } while ((confirm != 'Y') && (confirm != 'N') && (confirm != '\n'));
  29.     if(confirm == '\n') {
  30.         confirm = 'N';
  31.     }
  32.     strcpy(delcmd,"del");
  33.     if(confirm == 'N') {
  34.         for(x=1;x<=numfiles;x++) {
  35.             if((attrptr[x]&TAG) == TAG) {
  36.                 attrptr[x]&=0xFF;
  37.                 if((attrptr[x]&S_IFDIR) == S_IFDIR) {
  38.                     gotoxy(1,24);
  39.                     cleol();
  40.                     printf("     Deleting directory %s. Are you sure? (y/N)",nameptr[x]);
  41.                     do {
  42.                         ask = toupper(getchar());
  43.                         flush_kbd();
  44.                     } while ((ask != 'Y') && (ask != 'N') && (ask != '\n'));
  45.                     if(ask == 'Y') {
  46.                         gotoxy(1,24);
  47.                         cleol();
  48.                         printf("     Deleting Directory %s",nameptr[x]);
  49.                         strcpy(delcmd,"deldir -q ");
  50.                         strcat(delcmd,nameptr[x]);
  51.                         strcat(delcmd,">>>/nil");
  52.                         system(delcmd);
  53.                         strcpy(delcmd,"del");
  54.                         continue;
  55.                     } else {
  56.                         continue;
  57.                     }
  58.                 }
  59.                 strcat(delcmd," ");
  60.                 strcat(delcmd,nameptr[x]);
  61.                 strcat(delcmd," >>>/nil");
  62.                 gotoxy(1,24);
  63.                 cleol();
  64.                 printf("     Deleting %s.",nameptr[x]);
  65.                 system(delcmd);
  66.                 *(index(delcmd,' ')) = '\0';
  67.             }
  68.         }
  69.            free(delcmd);
  70.            commands();
  71.         return(PASS);
  72.     }
  73.     if(confirm == 'Y') {
  74.         for(x=1;x<=numfiles;x++) {
  75.             if((attrptr[x]&TAG) == TAG) {
  76.                 attrptr[x]&=0xFF;
  77.                 if((attrptr[x]&S_IFDIR) == S_IFDIR) {
  78.                     gotoxy(1,24);
  79.                     cleol();
  80.                     printf("     Deleting directory %s. Are you sure? (y/N)",nameptr[x]);
  81.                     do {
  82.                         ask = toupper(getchar());
  83.                         flush_kbd();
  84.                     } while ((ask != 'Y') && (ask != 'N') && (ask != '\n'));
  85.                     if(ask == 'Y') {
  86.                         gotoxy(1,24);
  87.                         cleol();
  88.                         printf("     Deleting Directory %s",nameptr[x]);
  89.                         strcpy(delcmd,"deldir -q ");
  90.                         strcat(delcmd,nameptr[x]);
  91.                         strcat(delcmd,">>>/nil");
  92.                         system(delcmd);
  93.                         strcpy(delcmd,"del");
  94.                         continue;
  95.                     } else {
  96.                         continue;
  97.                     }
  98.                 }
  99.                 strcat(delcmd," ");
  100.                 strcat(delcmd,nameptr[x]);
  101.                 gotoxy(1,24);
  102.                 cleol();
  103.                 printf("     %cDelete %s? y/N ",7,nameptr[x]);
  104.                 ask = toupper(getchar());
  105.                 flush_kbd();
  106.                 if(ask == 'Y') {
  107.                     strcat(delcmd," >>>/nil");
  108.                     gotoxy(1,24);
  109.                     cleol();
  110.                     printf("     Deleting %s",nameptr[x]);
  111.                     system(delcmd);
  112.                 }
  113.                 *(index(delcmd,' ')) = '\0';
  114.             }
  115.         }
  116.         free(delcmd);
  117.         commands();
  118.         return(PASS);
  119.     }
  120. }
  121.  
  122. /* EOF multidel.c */
  123.