#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 {
fname[i]=tolower(fname[i]);
}
break;
case 2:
if(flen==1)
{
printf("No Valid Filename Entered.");
getch();
goto endl;
}
v=0;
printf("%s is",fname);
attrib = get_file_attrib(fname);
if(attrib & FA_RDONLY)
{
printf("
Read-only file");
v=1;
}
if(attrib & FA_HIDDEN)
{
printf("
Hidden file");
v=1;
}
if(attrib & FA_SYSTEM)
{
printf("
System file");
v=1;
}
if(attrib & FA_LABEL)
{
printf("
Volume label");
v=1;
}
if(attrib & FA_DIREC)
{
printf("
Directory");
v=1;
}
if(attrib & FA_ARCH)
{
printf("
Archive file");
v=1;
}
printf(".");
if(v==1)
getch();
endl:
v=0;
break;
case 3:
if(flen==1)
{
printf("No Valid Filename Entered.");
getch();
goto endl1;
}
mode=1;
setfattr();
endl1:
break;
case 4:
if(flen==1)
{
printf("No Valid Filename Entered.");
getch();
goto endl2;
}
mode=2;
setfattr();
endl2:
break;
case 5:
goto end;
}
goto begin;
end:
clrscr();
}
void setattr(int row,int col,int attr)
{
int i;
for(i=0;i<23;i++)
{
*(scr+row*160+col*2+1)=attr;
col++;
}
}
int get_file_attrib(char fname[40])
{
return(_chmod(fname,0));
}
void setfattr()
{
begin1:
r=4;
c=20;
clrscr();
gotoxy(21,5);
printf("1. Read Only.");
gotoxy(21,6);
printf("2. Hidden.");
gotoxy(21,7);
printf("3. System.");
gotoxy(21,8);
printf("4. Archive.");
gotoxy(21,9);
printf("5. Back.");
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();
attrib=get_file_attrib(fname);
if(mode==1)
{
switch(b)
{
case 1:
_chmod(fname,1,attrib|FA_RDONLY);
break;
case 2:
_chmod(fname,1,attrib|FA_HIDDEN);
break;
case 3:
_chmod(fname,1,attrib|FA_SYSTEM);
break;
case 4:
_chmod(fname,1,attrib|FA_ARCH);
break;
case 5:
goto end1;
}
}
if(mode==2)
{
switch(b)
{
case 1:
v=~FA_RDONLY;
attrib=attrib&v;
_chmod(fname,1,attrib);
break;
case 2:
v=~FA_HIDDEN;
attrib=attrib&v;
_chmod(fname,1,attrib);
break;
case 3:
v=~FA_SYSTEM;
attrib=attrib&v;
_chmod(fname,1,attrib);
break;
case 4:
v=~FA_ARCH;
attrib=attrib&v;
_chmod(fname,1,attrib);
break;
case 5:
goto end1;
}
}
v=0;
goto begin1;
end1:
clrscr();
mode=0;
}