// TMsgDirGetDirContents::Unpack
// Virtual method from TMessage.  Extracts data from message buffer.
void
TMsgDirGetDirContentsReply::Unpack(void)
{
	WTRACE("TMsgDirGetDirContentsReply::Unpack");
	TMessage::Unpack();

	if ((GetServiceType() != WONMsg::DirServer) ||
	    (GetMessageType() != WONMsg::DirGetDirContentsReply))
	{
		WDBG_AH("TMsgDirGetDirContentsReply::Unpack Not a DirGetDirContentsReply message!");
		throw WONMsg::BadMsgException(*this, __LINE__, __FILE__,
		                              "Not a DirGetDirContentsReply message.");
	}

	WDBG_LL("TMsgDirGetDirContentsReply::Unpack Reading message data");
	mStatus = static_cast<ServerStatus>(static_cast<short>(ReadShort()));
	unsigned short anEntryCt = ReadShort();

	WDBG_LL("TMsgDirGetDirContentsReply::Unpack Reading " << anEntryCt << "entries.");
	mEntries.clear();
	for (int i=0; i < anEntryCt; i++)
	{
		DirServerEntry anEntry;
		UnpackEntry(anEntry);
		mEntries.push_back(anEntry);
	}
}
Пример #2
0
int Unpack(wxFile& pkg_f, std::string src, std::string dst)
{
	PKGHeader* m_header = (PKGHeader*) malloc (sizeof(PKGHeader));

	wxFile dec_pkg_f;
	std::string decryptedFile = wxGetCwd() + "/dev_hdd1/" + src + ".dec";

	dec_pkg_f.Create(decryptedFile, true);
	
	if (Decrypt(pkg_f, dec_pkg_f, m_header) < 0)
		return -1;
	
	dec_pkg_f.Close();

	wxFile n_dec_pkg_f(decryptedFile, wxFile::read);

	std::vector<PKGEntry> m_entries;
	m_entries.resize(m_header->file_count);

	PKGEntry *m_entries_ptr = &m_entries[0];
	if (!LoadEntries(n_dec_pkg_f, m_header, m_entries_ptr))
		return -1;

	wxProgressDialog pdlg("PKG Decrypter / Installer", "Please wait, unpacking...", m_entries.size(), 0, wxPD_AUTO_HIDE | wxPD_APP_MODAL);

	for (const PKGEntry& entry : m_entries)
	{
		UnpackEntry(n_dec_pkg_f, entry, dst + src + "/");
		pdlg.Update(pdlg.GetValue() + 1);
	}
	pdlg.Update(m_entries.size());

	n_dec_pkg_f.Close();
	wxRemoveFile(decryptedFile);

	return 0;
}