// DWBS ------------------------------------------------------------------ DWBS
//
// PLATFORM		: ALL
// PRODUCT		: BIT_DEMON
// VISIBILITY	: PUBLIC
//
// DWBS ------------------------------------------------------------------ DWBS

#include <bdLobby/bdStorage/bdGetFileResult.h>

bdGetFileResult::~bdGetFileResult()
{
	m_files.clear();
}

bdBool bdGetFileResult::handleResult(const bdUInt numResults, 
									 bdBitBufferRef buffer)
{
	bdBool ok = true;

	for(bdUInt i=0; ok && (i < numResults); i++)
	{
		bdUInt32 size = 0;
		ok = buffer->readUInt32(size);

		bdLobbyFileRef file;
		if(ok)
		{
			file = new bdLobbyFile(size);
			ok = file.notNull();
			ok = ok && file->deserialize(buffer);
		}

		if(ok)
		{
			m_files.pushBack(file);
		}
	}

	m_numResults = m_files.getSize();
	return ok;
}
