i am tring to get the contents of a html file which is present inside the tar file(i am using visual c++ to accomplish my task). my approach is to store the tar in a buffer using a stream and then store the contents of html in another buffer.Then using buffer going to the file name of each file present in tar file at location buffer[0-100](at this location we have the file name)and store the file name in "contents"(in my case) and search if it has the extension.html file ??
If it has .html in the name of the file then store its contents from the location buffer[PreviousFileSizes +512](by PreviousFileSizes i mean there were some files before this html file so we have to add their sizes in the buffer index to go to the correct location- i mean i am not assuming that the first file in tar file is html file-In my code i denote this PreviousFileSizes by "skip" - that means this much size to skip to go to our html file).
my code to achieve it is-
int skip=0;
char contents [100];
//char test[1000];
do
{
int SizeOfFile = CreateOctalToInteger(&buffer[skip+124],11);
size_t distance= ((SizeOfFile%512) ? SizeOfFile + 512 - (SizeOfFile%512) : SizeOfFile );
size_t skip= distance +512;
memcpy(contents,&buffer[skip],100);
}
while(strstr(contents,".html") != NULL);
am i going right ??Please correct me if there is anything wrong in my logic ??