home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
APPS
/
dm.lzh
/
multiattr.c
< prev
next >
Wrap
Text File
|
1995-10-26
|
2KB
|
108 lines
/* multiattr.c function for DISKMASTER.C */
/* copyright (c) 1995 by Bob Devries */
/* email: bdevries@gil.ipswichcity.qld.gov.au */
/* changes the attributes of multiple files in current directory */
#include "diskmaster.h"
#include <strings.h>
#include <stdio.h>
int
multiattr(numfiles)
int numfiles;
{
extern char **nameptr;
extern short *attrptr;
char *attrcmd;
char *newattr, oldattr[8], *malloc();
char *getattr();
int confirm, ask, success, x;
attrcmd = malloc(numfiles*32+256);
newattr = malloc(80);
strcpy(oldattr,"dsewrewr");
gotoxy(1,24);
cleol();
printf(" %cChange attributes of tagged files to: ",7);
success = lineinput(newattr,80);
if((success == FAIL) || (*newattr == '\0')) {
free(attrcmd);
free(newattr);
commands();
return(FAIL);
}
if(index(newattr,'d') != NULL) {
gotoxy(1,24);
cleol();
printf(" %cCan't change the directory attribute!",7);
free(attrcmd);
free(newattr);
sleep(1);
commands();
return(FAIL);
}
gotoxy(1,24);
cleol();
printf(" %cConfirm each attribute change? y/N ",7);
do {
confirm = toupper(getchar());
flush_kbd();
} while ((confirm != 'Y') && (confirm != 'N') && (confirm != '\n'));
if(confirm == '\n') {
confirm = 'N';
}
strcpy(attrcmd,"attr ");
strcat(attrcmd,newattr);
strcat(attrcmd," ");
if(confirm == 'N') {
for(x=1; x<=numfiles;x++) {
if((attrptr[x]&TAG) == TAG) {
strcat(attrcmd,nameptr[x]);
strcat(attrcmd," ");
attrptr[x]&=0xFF;
}
}
strcat(attrcmd,">>>/nil");
gotoxy(1,24);
cleol();
printf(" Working...");
system(attrcmd);
free(attrcmd);
free(newattr);
commands();
return(PASS);
}
for(x=1;x<=numfiles;x++) {
if((attrptr[x]&TAG) == TAG) {
attrptr[x]&=0xFF;
gotoxy(1,24);
cleol();
printf(" %cChange attributes of %s from %s to %s? y/N ",7,nameptr[x],getattr(oldattr,attrptr[x]&0xFF),newattr);
do {
ask = toupper(getchar());
flush_kbd();
} while((ask != 'Y') && (ask != 'N') && (ask != '\n'));
if (ask == '\n') {
ask = 'N';
}
if (ask == 'Y') {
strcat(attrcmd,nameptr[x]);
strcat(attrcmd,">>>/nil");
gotoxy(1,24);
cleol();
printf(" Changing attributes on %s to %s...",nameptr[x],newattr);
system(attrcmd);
*(rindex(attrcmd,' ') + 1) = '\0';
}
}
}
free(attrcmd);
free(newattr);
commands();
return(PASS);
}
/* EOF multiattr.c */