#include<stdio.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
union
{
char no[4];
int num;
#include<conio.h>
#include<stdio.h>
#include<string.h>
union
{
char no[4];
int num;
}u1;
int main()
{
unsigned char *root=(char*)malloc(512*13);
unsigned char *try1;
unsigned char *try2;
unsigned char *data=(char*)malloc(512);
unsigned char *datf=(char*)malloc(512*9);
char filename[20];
int i,j,found=0,clust,fat=0,var=0;
clrscr();
asm{
mov ax,00h
mov cx,13;
mov dx,13h;
mov bx,root;
int 25h;
}
printf("\nenter the name of file");
gets(filename);
try2=root;
for(i=0;i<512*13;i+=32)
{
root=try2;
root=root+i;
try1=root;
for(j=0;j<strlen(filename);j++)
{
if (filename[j]=='.')
{
root=try1;
root=root+8;
continue;
}
else if(*(root)!=filename[j])
{
j=0;
break;
}
else
{
root++;
continue;
}
}
if (j==strlen(filename))
{
found=1;
break;
}
else
{
continue;
}
}
if (found==0)
printf("\nnot found");
else
{
printf("\nfound");
root=try1;
root=root+26;
clust=*(root+1)*256+*(root);
printf("\nstarting cluster no %d\t",clust);
var=clust;
do
{
clust=clust+31;
asm{
mov ax,00h
mov cx,01h
mov bx,data
mov dx,clust
int 25h
}
for(i=0;i<512;i++)
{
if(*(data+i)==0)
{
printf("\nend of file");
found=2;
break;
}
printf("%c",*(data+i));
}
if (found==2)
break;
fat=(int)var*3/2;
asm{
mov ax,00h
mov cx,09h
mov bx,datf
mov dx,01
int 25h
}
datf=datf+fat;
u1.no[0]=*(datf);
u1.no[1]=*(datf+1);
if((var)%2==1)
{
clust=u1.num>>4;
var=clust;
}
else
{
clust=u1.num&0xfff;
var=clust;
}
if (clust<=0xfff&&clust >=0xff8)
break;
}while(1);
}
getch();
return 1;
}
No comments:
Post a Comment