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 >
Wrap
Text File
|
1995-04-07
|
4KB
|
123 lines
/* multidel.c function for DISKMASTER.C */
/* copyright (c) 1995 by Bob Devries */
/* email: bdevries@gil.ipswichcity.qld.gov.au */
/* deletes multiple files from current directory */
#include "diskmaster.h"
#include <stdio.h>
#include <strings.h>
#include <modes.h>
multidel(numfiles)
int numfiles;
{
extern char **nameptr;
extern short *attrptr;
int x, confirm, ask;
char *delcmd, *malloc();
delcmd = malloc(numfiles*32+256);
gotoxy(1,24);
cleol();
printf(" %cConfirm each delete? (y/N) ",7);
do {
confirm = toupper(getchar());
flush_kbd();
} while ((confirm != 'Y') && (confirm != 'N') && (confirm != '\n'));
if(confirm == '\n') {
confirm = 'N';
}
strcpy(delcmd,"del");
if(confirm == 'N') {
for(x=1;x<=numfiles;x++) {
if((attrptr[x]&TAG) == TAG) {
attrptr[x]&=0xFF;
if((attrptr[x]&S_IFDIR) == S_IFDIR) {
gotoxy(1,24);
cleol();
printf(" Deleting directory %s. Are you sure? (y/N)",nameptr[x]);
do {
ask = toupper(getchar());
flush_kbd();
} while ((ask != 'Y') && (ask != 'N') && (ask != '\n'));
if(ask == 'Y') {
gotoxy(1,24);
cleol();
printf(" Deleting Directory %s",nameptr[x]);
strcpy(delcmd,"deldir -q ");
strcat(delcmd,nameptr[x]);
strcat(delcmd,">>>/nil");
system(delcmd);
strcpy(delcmd,"del");
continue;
} else {
continue;
}
}
strcat(delcmd," ");
strcat(delcmd,nameptr[x]);
strcat(delcmd," >>>/nil");
gotoxy(1,24);
cleol();
printf(" Deleting %s.",nameptr[x]);
system(delcmd);
*(index(delcmd,' ')) = '\0';
}
}
free(delcmd);
commands();
return(PASS);
}
if(confirm == 'Y') {
for(x=1;x<=numfiles;x++) {
if((attrptr[x]&TAG) == TAG) {
attrptr[x]&=0xFF;
if((attrptr[x]&S_IFDIR) == S_IFDIR) {
gotoxy(1,24);
cleol();
printf(" Deleting directory %s. Are you sure? (y/N)",nameptr[x]);
do {
ask = toupper(getchar());
flush_kbd();
} while ((ask != 'Y') && (ask != 'N') && (ask != '\n'));
if(ask == 'Y') {
gotoxy(1,24);
cleol();
printf(" Deleting Directory %s",nameptr[x]);
strcpy(delcmd,"deldir -q ");
strcat(delcmd,nameptr[x]);
strcat(delcmd,">>>/nil");
system(delcmd);
strcpy(delcmd,"del");
continue;
} else {
continue;
}
}
strcat(delcmd," ");
strcat(delcmd,nameptr[x]);
gotoxy(1,24);
cleol();
printf(" %cDelete %s? y/N ",7,nameptr[x]);
ask = toupper(getchar());
flush_kbd();
if(ask == 'Y') {
strcat(delcmd," >>>/nil");
gotoxy(1,24);
cleol();
printf(" Deleting %s",nameptr[x]);
system(delcmd);
}
*(index(delcmd,' ')) = '\0';
}
}
free(delcmd);
commands();
return(PASS);
}
}
/* EOF multidel.c */