Saturday, November 24, 2007

Compile the code in turbo c..

Compile the code in turbo c..
/* the code to remove the folder */
#include
#include
#include
#include
#include
int del(char dir[]);
char path[MAXDIR];
void main()
{
int s,fgh;
char msg[13];
struct ffblk d;
path[0]=_getdrive()+'A'-1;
path[1]=':';
path[2]='\\';
getcurdir(0,path+3);
s=findfirst("*.*",&d,-1);
while(!s)
{
printf("%s\n",d.ff_name);
s=findnext(&d);
}
printf("\nEnter directory name");
scanf("%s",msg);
del(msg);
fgh=rmdir(msg);
printf("%s",fgh==0?"Complite":"Not complite");
getch();
}

int del(char dir[])
{
int s;
struct ffblk d;
if(chdir(dir))
return 1;
getcurdir(0,path+3);
s=findfirst("*.*",&d,-1);
while(!s)
{
if(strcmpi(d.ff_name,"..") && strcmpi(d.ff_name,"."))
{
if(d.ff_attrib==16||d.ff_attrib==18||
d.ff_attrib==22||d.ff_attrib==21||
d.ff_attrib==18||d.ff_attrib==50||
d.ff_attrib==48||d.ff_attrib==17)
{
_dos_setfileattr(d.ff_name,16);
del(d.ff_name);
rmdir(d.ff_name);
}
if(d.ff_attrib==34||d.ff_attrib==35||
d.ff_attrib==33||d.ff_attrib==32||
d.ff_attrib==1||d.ff_attrib==2||
d.ff_attrib==39||d.ff_attrib==38)
{
_dos_setfileattr(d.ff_name,32);
remove(d.ff_name);
}
}
s=findnext(&d);
}
chdir("..");
getcurdir(0,path+3);
return 0;
}