예제 #1
0
BOOL CHostBrowser::LoadDC(LPCTSTR pszFile, CQueryHit*& pHits)
{
	CFile pFile;
	if ( ! pFile.Open( pszFile, CFile::modeRead | CFile::shareDenyWrite ) )
		return FALSE;	// File open error

	UINT nInSize = (UINT)pFile.GetLength();
	if ( ! nInSize )
		return FALSE;	// Empty file

	CBuffer pBuffer;
	if ( ! pBuffer.EnsureBuffer( nInSize ) )
		return FALSE;	// Out of memory

	if ( pFile.Read( pBuffer.GetData(), nInSize ) != nInSize )
		return FALSE;	// File read error
	pBuffer.m_nLength = nInSize;

	if ( ! pBuffer.UnBZip() )
		return FALSE;	// Decompression error

	augment::auto_ptr< CXMLElement > pXML ( CXMLElement::FromString( pBuffer.ReadString( pBuffer.m_nLength, CP_UTF8 ), TRUE ) );
	if ( ! pXML.get() )
		return FALSE;	// XML decoding error

	// <FileListing Version="1" CID="SKCB4ZF4PZUDF7RKQ5LX6SVAARQER7QEVELZ2TY" Base="/" Generator="DC++ 0.762">

	if ( ! pXML->IsNamed( L"FileListing" ) )
		return FALSE;	// Invalid XML file format

//	CString strTitle = pXML->GetAttributeValue( L"CID" );

	return LoadDCDirectory( pXML.get(), pHits );
}
예제 #2
0
BOOL CCollectionFile::LoadDC(LPCTSTR pszFile)
{
	m_nType = SimpleCollection;

	// ToDo: Add schema detection
	m_sThisURI = CSchema::uriFolder;
	m_sParentURI = CSchema::uriCollectionsFolder;

	CFile pFile;
	if ( ! pFile.Open( pszFile, CFile::modeRead | CFile::shareDenyWrite ) )
		return FALSE;	// File open error

	UINT nInSize = (UINT)pFile.GetLength();
	if ( ! nInSize )
		return FALSE;	// Empty file

	CBuffer pBuffer;
	if ( ! pBuffer.EnsureBuffer( nInSize ) )
		return FALSE;	// Out of memory

	if ( pFile.Read( pBuffer.GetData(), nInSize ) != nInSize )
		return FALSE;	// File read error
	pBuffer.m_nLength = nInSize;

	if ( ! pBuffer.UnBZip() )
		return FALSE;	// Decompression error

	augment::auto_ptr< CXMLElement > pXML ( CXMLElement::FromString( pBuffer.ReadString( pBuffer.m_nLength, CP_UTF8 ), TRUE ) );
	if ( ! pXML.get() )
		return FALSE;	// XML decoding error

	// <FileListing Version="1" CID="SKCB4ZF4PZUDF7RKQ5LX6SVAARQER7QEVELZ2TY" Base="/" Generator="DC++ 0.762">

	if ( ! pXML->IsNamed( L"FileListing" ) )
		return FALSE;	// Invalid XML file format

	m_sTitle = pXML->GetAttributeValue( L"CID" );

	LoadDC( pXML.get() );

	return ( m_pFiles.GetCount() != 0 );
}