1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-20 20:23:03 +02:00
vcmi/client/CSndHandler.h

88 lines
1.8 KiB
C
Raw Normal View History

#ifndef __CSNDHANDLER_H__
#define __CSNDHANDLER_H__
#include <vector>
#include <iosfwd>
#include <map>
#include <SDL_stdinc.h>
2009-04-22 21:28:01 +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
*
*/
namespace boost
{
namespace iostreams
{
class mapped_file_source;
}
}
struct MemberFile
{
std::ifstream * ifs;
int length;
};
2009-10-11 19:08:01 +03:00
// sound entry structure in catalog
struct soundEntry
{
char filename[40];
2009-10-11 19:08:01 +03:00
Uint32 offset; /* little endian */
Uint32 size; /* little endian */
};
2009-10-11 19:08:01 +03:00
// video entry structure in catalog
struct videoEntry
{
char filename[40];
2009-10-11 19:08:01 +03:00
Uint32 offset; /* little endian */
};
class CMediaHandler
{
protected:
struct Entry
{
std::string name;
2009-04-22 21:28:01 +03:00
unsigned int size;
unsigned int offset;
};
2009-04-22 21:28:01 +03:00
boost::iostreams::mapped_file_source *mfile;
2009-04-22 21:28:01 +03:00
public:
std::vector<Entry> entries;
std::map<std::string, int> fimap; // map of file and index
~CMediaHandler(); //d-tor
CMediaHandler(std::string fname); //c-tor
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
void extract(int index, std::string dstfile); //saves selected file
MemberFile getFile(std::string name);//nie testowane - sprawdzic
2009-04-22 21:28:01 +03:00
const char * extract (int index, int & size); //return selecte file - NIE TESTOWANE
};
class CSndHandler: public CMediaHandler
{
public:
CSndHandler(std::string fname);
};
class CVidHandler: public CMediaHandler
{
public:
CVidHandler(std::string fname);
};
#endif // __CSNDHANDLER_H__