Exemple #1
0
	void PackFile::Load( const Bootil::BString& strName )
	{
		Msg( "LoadinG File!! %s\n", strName.c_str() );

		AutoBuffer buffer;

		if ( !Bootil::File::Read( strName, buffer ) )
		{
			Warning( "C0ouldn;t oipen!\n" );
			return;
		}

		buffer.SetPos( 0 );

		// Check file signature
		{
			Bootil::BString strSig = buffer.ReadString();
			Msg( "Signature [%s]\n", strSig.c_str() ); 
			if ( strSig != "FILEPACK001" ) return;
		}

		unsigned int iOffset = 0;

		while ( true )
		{
			if ( buffer.ReadType<unsigned char>() != 1 ) break;

			unsigned int iSize = buffer.ReadType<unsigned int>();
			Bootil::BString strName = buffer.ReadString();

			Msg( "%s %i\n", strName.c_str(), iSize );

			FileEntry fe;
			fe.iLength = iSize;
			fe.iStartPos = iOffset;

			m_FileMap[ strName ] = fe;

			iOffset+= iSize;
		}

		Msg( "End Pos Files: %i\n", iOffset );
		Msg( "End Pos Actual: %i\n", buffer.GetWritten() - buffer.GetPos() );

		// The left over data goes into m_Buffer
		m_Buffer.Clear();
		m_Buffer.Write( buffer.GetCurrent(), buffer.GetWritten() - buffer.GetPos() );
	}
Exemple #2
0
			bool File::AddFile( const BString & ZipName, const BString & LocalFileName )
			{
				EnsureWriter();
				AutoBuffer file;

				if ( !Bootil::File::Read( LocalFileName, file ) )
				{ return false; }

				if ( ZR_OK != XZip::ZipAdd( ( XZip::HZIP )m_Write, ZipName.c_str(), file.GetBase(), file.GetWritten() ) )
				{ return false; }

				return true;
			}