Mega Code Archive
Menu Driven File Attribute Changing Utility
#include
#include
#include
#define SE 112
#define US 7
int get_file_attrib(char fname[40]);
void setfattr(void);
void setattr(int,int,int);
char fname[40];
char far *scr;
char far *mode1;
FILE *fp;
int mode=0;
int r,c,i,j,b,attrib,flen=1;
int v=0;
char ch,t;
void main()
{
_AH=0;
_AL=3;
geninterrupt(0x10);
if((*mode1 &0x30)== 0x30)
scr=(char far*) 0xb0000000;
else
scr=(char far*) 0xb8000000;
begin:
r=4;
c=20;
clrscr();
gotoxy(21,5);
printf("1. Select a File.");
gotoxy(21,6);
printf("2. View Attributes.");
gotoxy(21,7);
printf("3. Set Attributes.");
gotoxy(21,8);
printf("4. Remove Attributes.");
gotoxy(21,9);
printf("5. Exit.");
gotoxy(21,11);
printf("Enter Choice: [1]");
while(ch!=13)
{
for(i=4;i<11;i++)
setattr(i,20,US);
setattr(r,c,SE);
gotoxy(36,11);
ch=getch();
if(ch=='H'||ch=='h')
{
if(r==4)
r=4;
else
r--;
}
else if(ch=='P'||ch=='p')
{
if(r==8)
r=8;
else
r++;
}
else if(ch=='1')
{
r=4;
}
else if(ch=='2')
{
r=5;
}
else if(ch=='3')
{
r=6;
}
else if(ch=='4')
{
r=7;
}
else if(ch=='5')
{
r=8;
}
t=r+48-3;
printf("%c",t);
gotoxy(36,13);
}
ch=' ';
b=r-3;
clrscr();
switch(b)
{
case 1:
strcpy(fname,NULL);
flen=0;
printf("Please Enter Valid Filename with Extension: ");
scanf("%[^
]s",fname);
attrib = get_file_attrib(fname);
if(attrib & FA_LABEL)
{
flen=2;
}
if(attrib & FA_DIREC)
{
flen=2;
}
if(flen!=2)
{
fp=fopen(fname,"rb");
if(fp==NULL)
{
printf("NON_EXISTING FILE
");
flen=1;
getch();
}
fclose(fp);
}
v=strlen(fname);
for(i=0;i