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

#include <bdLobby/bdStorage/bdListFilesResult.h>

bdListFilesResult::~bdListFilesResult()
{
	m_fileHeaders.clear();
}

bdBool bdListFilesResult::handleResult(const bdUInt numResults, 
									   bdBitBufferRef buffer)
{
	bdBool ok = true;
	for (bdUInt i=0; ok && (i < numResults); i++)
	{		
		bdUInt32 size = 0;
		ok = buffer->readUInt32(size);
		
		bdLobbyFileHeaderRef file;
		if(ok)
		{
			file = new bdLobbyFileHeader();
			ok = file.notNull();
			ok = ok && file->deserialize(buffer);
			if(ok)
			{
				file->setFileSize(size);
			}
		}
		
		if(ok)
		{
			m_fileHeaders.pushBack(file);
		}
	}

	m_numResults = m_fileHeaders.getSize();

	return ok;
}

