This topic is now archived and is closed to further replies.


Just getting crap out of my file

Recommended Posts

I am currently writing an archive class to store my files. To add a file to an archive I am doing this:
bool CArchive::AddFile(LPSTR strFileName) {
	LPBYTE pbyFileContent = NULL;
	DWORD dwSize = 0;
	CDataPackage * pData = NULL;
	std::ifstream FileIn(strFileName, std::ios::binary);
	char c;

	while(FileIn.good()) {, sizeof(char));

	pbyFileContent = new BYTE[dwSize];, std::ios::binary); *)pbyFileContent, dwSize);

	pData = new CDataPackage(m_pDebug);
	memcpy(pData->GetData(), pbyFileContent, dwSize);

	m_Files.push_back(new ARCHIVEFILE);
	m_Files.back()->strFileName = strdup(strFileName);
	m_Files.back()->pData = pData;

	m_FileEntries.resize(m_FileEntries.size() + 1);
	strcpy(m_FileEntries.back().strFileName, strFileName);
	m_FileEntries.back().dwBegin = 0;
	m_FileEntries.back().dwEnd = 0;
	m_FileEntries.back().dwUncompressedSize = dwSize;
	return true;
For I do not know how to determine the file size with std::ifstream I have to do it manually. But after reading the pbyFileContent buffer it still contains only rubbish. I am testing this by reading in a text file so I should be able to understand what is read in but I am not because the buffer is full of crap... Any ideas?

Share this post

Link to post
Share on other sites