tar 파일 안에있는 파일 중 하나 인 html 파일을 얻으려고합니다. 그 파일의 올바른 또는 정확한 정보를 모르고 있습니다. 아니 ?? 내가 틀렸다면 나를 가르쳐주세요. 내 생각은 -tar 파일 안에있는 html 파일의 내용을 얻으려고 시도합니다.
나는 스트림을 tar 파일로 만들고 그 내용을 버퍼에 저장하기 위해 strstr 명령을 사용하여 tar 파일 내부의 html 파일을 검색한다 (내 tar 파일에서 알 수 있듯이). html 내용은 "<! doctype html"에서 시작하여 < "/ html>"으로 끝납니다. 그래서 실제로 HTML 파일 인 내용을로드 할 것입니다. 내 접근 방식이 맞습니까?
문제는 내가 버퍼에 매우 큰 크기를 줄 때이다. (그러나 HTML 크기의 다른 많은 파일들도 포함하는 tar 파일의 크기가 더 작다.) 디버깅 할 때 스택 오버 플로우가 발생한다. 하지만 작은 인덱스를 줄 때 메모장에 tar 파일을 열면 시작 부분에있는 다른 파일의 내용을 보여줍니다 (메모장에 tar 파일을 열어 확인한 내용은 tar 파일에 실제로 있지만 시작시에 나타납니다). tar 파일의 그래서 내가 파일의 중간에있는 html 파일 (실제로는 매우 큰 인덱스가 필요함)에 액세스하기 위해 버퍼의 인덱스를 증가시킬 때 디버깅시 stackoverflow를 제공합니다. 내 코드
HRESULT AMEPreviewHandler:: CreateHtmlPreview(IStream *m_pStream) //this function is called from
// somewhere
ULONG CbRead;
const int Size= 115000 ;
char Buffer[Size+1];
(m_pStream)->Read(Buffer, Size, &CbRead);
Buffer[CbRead ] = L'\0';
char *compare= "<!doctype html"; //this we have to search in tar file
// content because the html file contents starts from here
char * StartPosition;
StartPosition = strstr (Buffer,compare); //StartPosition gives Bad
// pointer when Size is small on debugging at this small size i can see some contents in buffer which i
//can find in tar file at starting
__int64 count=0;
while (StartPosition!=NULL)
{
MessageBox(m_hwndPreview,L"hurr inside the while loop",L"BTN WND",MB_ICONINFORMATION);
count=StartPosition-Buffer+1; //to get the location of
//"<!doctype html";
}
MessageBox(m_hwndPreview,L"wafter the while loop in CreateHtmlPreview ",L"BTN WND",MB_ICONINFORMATION);
return true;
}
내 접근 방식은 tar 파일이 올바른지 내부 html 파일의 파일 내용을 얻을 수있다 알려주세요 - 이것도? 왜 내가 tar 파일의 중간에 loctaed 버퍼의 내용에 액세스하기 위해 버퍼에 큰 인덱스를 줄 때 스택 오버플로를 제공합니까? 심지어 내가 크기를 선언하면 크기가 tar 파일의 크기보다 작은 경우 수동으로 볼 수 있습니까?