2011-12-14 00:23:17 +03:00
# pragma once
2009-04-16 14:14:13 +03:00
2009-04-24 00:09:10 +03:00
# include <iosfwd>
2009-10-11 19:05:40 +03:00
# include <SDL_stdinc.h>
2009-04-16 14:14:13 +03:00
2009-04-22 21:28:01 +03:00
2009-04-15 17:03:31 +03:00
/*
* CSndHandler . h , part of VCMI engine
*
* Authors : listed in file AUTHORS in main folder
*
* License : GNU General Public License v2 .0 or later
* Full text of license available in license . txt file , in main folder
*
2009-04-16 14:14:13 +03:00
*/
2009-04-24 00:09:10 +03:00
namespace boost
{
namespace iostreams
{
class mapped_file_source ;
}
}
2009-04-16 14:14:13 +03:00
struct MemberFile
{
std : : ifstream * ifs ;
int length ;
} ;
2009-06-19 07:27:12 +03:00
2009-10-11 19:08:01 +03:00
// video entry structure in catalog
2009-10-11 19:05:40 +03:00
struct videoEntry
{
char filename [ 40 ] ;
2009-10-11 19:08:01 +03:00
Uint32 offset ; /* little endian */
2009-10-11 19:05:40 +03:00
} ;
2009-06-19 07:27:12 +03:00
class CMediaHandler
2009-04-16 14:14:13 +03:00
{
2009-06-19 07:27:12 +03:00
protected :
2009-04-16 14:14:13 +03:00
struct Entry
{
std : : string name ;
2011-12-14 00:23:17 +03:00
ui32 size ;
ui32 offset ;
2011-08-07 22:14:46 +03:00
const char * data ;
2009-04-16 14:14:13 +03:00
} ;
2009-04-22 21:28:01 +03:00
2011-08-07 22:14:46 +03:00
std : : vector < boost : : iostreams : : mapped_file_source * > mfiles ;
2011-08-27 01:52:02 +03:00
boost : : iostreams : : mapped_file_source * add_file ( std : : string fname , bool important = true ) ; //if not important, then we don't print warning when the file is missing
2009-04-22 21:28:01 +03:00
2009-04-16 14:14:13 +03:00
public :
std : : vector < Entry > entries ;
2009-06-19 07:27:12 +03:00
std : : map < std : : string , int > fimap ; // map of file and index
~ CMediaHandler ( ) ; //d-tor
2009-04-16 14:14:13 +03:00
void extract ( std : : string srcfile , std : : string dstfile , bool caseSens = true ) ; //saves selected file
2009-04-22 21:28:01 +03:00
const char * extract ( std : : string srcfile , int & size ) ; //return selecte file data, NULL if file doesn't exist
2009-04-16 14:14:13 +03:00
void extract ( int index , std : : string dstfile ) ; //saves selected file
2009-04-22 21:28:01 +03:00
const char * extract ( int index , int & size ) ; //return selecte file - NIE TESTOWANE
2009-04-16 14:14:13 +03:00
} ;
2009-06-19 07:27:12 +03:00
class CVidHandler : public CMediaHandler
{
public :
2011-08-07 22:14:46 +03:00
void add_file ( std : : string fname ) ;
2009-04-16 14:14:13 +03:00
} ;