2009-04-16 11:14:13 +00:00
# ifndef __CSNDHANDLER_H__
# define __CSNDHANDLER_H__
# include <vector>
2009-04-23 21:09:10 +00:00
# include <iosfwd>
2009-04-16 11:14:13 +00:00
# include <map>
2009-10-11 16:05:40 +00:00
# include <SDL_stdinc.h>
2009-04-16 11:14:13 +00:00
2009-04-22 18:28:01 +00:00
2009-04-15 14:03:31 +00: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 11:14:13 +00:00
*/
2009-04-23 21:09:10 +00:00
namespace boost
{
namespace iostreams
{
class mapped_file_source ;
}
}
2009-04-16 11:14:13 +00:00
struct MemberFile
{
std : : ifstream * ifs ;
int length ;
} ;
2009-06-19 04:27:12 +00:00
2009-10-11 16:08:01 +00:00
// sound entry structure in catalog
2009-10-11 16:05:40 +00:00
struct soundEntry
{
char filename [ 40 ] ;
2009-10-11 16:08:01 +00:00
Uint32 offset ; /* little endian */
Uint32 size ; /* little endian */
2009-10-11 16:05:40 +00:00
} ;
2009-10-11 16:08:01 +00:00
// video entry structure in catalog
2009-10-11 16:05:40 +00:00
struct videoEntry
{
char filename [ 40 ] ;
2009-10-11 16:08:01 +00:00
Uint32 offset ; /* little endian */
2009-10-11 16:05:40 +00:00
} ;
2009-06-19 04:27:12 +00:00
class CMediaHandler
2009-04-16 11:14:13 +00:00
{
2009-06-19 04:27:12 +00:00
protected :
2009-04-16 11:14:13 +00:00
struct Entry
{
std : : string name ;
2009-04-22 18:28:01 +00:00
unsigned int size ;
unsigned int offset ;
2011-08-07 19:14:46 +00:00
const char * data ;
2009-04-16 11:14:13 +00:00
} ;
2009-04-22 18:28:01 +00:00
2011-08-07 19:14:46 +00:00
std : : vector < boost : : iostreams : : mapped_file_source * > mfiles ;
2011-08-26 22:52:02 +00: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 18:28:01 +00:00
2009-04-16 11:14:13 +00:00
public :
std : : vector < Entry > entries ;
2009-06-19 04:27:12 +00:00
std : : map < std : : string , int > fimap ; // map of file and index
~ CMediaHandler ( ) ; //d-tor
2009-04-16 11:14:13 +00:00
void extract ( std : : string srcfile , std : : string dstfile , bool caseSens = true ) ; //saves selected file
2009-04-22 18:28:01 +00:00
const char * extract ( std : : string srcfile , int & size ) ; //return selecte file data, NULL if file doesn't exist
2009-04-16 11:14:13 +00:00
void extract ( int index , std : : string dstfile ) ; //saves selected file
MemberFile getFile ( std : : string name ) ; //nie testowane - sprawdzic
2009-04-22 18:28:01 +00:00
const char * extract ( int index , int & size ) ; //return selecte file - NIE TESTOWANE
2009-04-16 11:14:13 +00:00
} ;
2009-06-19 04:27:12 +00:00
class CSndHandler : public CMediaHandler
2009-04-16 11:14:13 +00:00
{
public :
2011-08-26 22:52:02 +00:00
void add_file ( std : : string fname , bool important = true ) ; //if not important, then we don't print warning when the file is missing
2009-06-19 04:27:12 +00:00
} ;
class CVidHandler : public CMediaHandler
{
public :
2011-08-07 19:14:46 +00:00
void add_file ( std : : string fname ) ;
2009-04-16 11:14:13 +00:00
} ;
# endif // __CSNDHANDLER_H__