CSndHandler.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include <iosfwd>
  3. #include <SDL_stdinc.h>
  4. /*
  5. * CSndHandler.h, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. namespace boost
  14. {
  15. namespace iostreams
  16. {
  17. class mapped_file_source;
  18. }
  19. }
  20. struct MemberFile
  21. {
  22. std::ifstream * ifs;
  23. int length;
  24. };
  25. // video entry structure in catalog
  26. struct videoEntry
  27. {
  28. char filename[40];
  29. Uint32 offset; /* little endian */
  30. };
  31. class CMediaHandler
  32. {
  33. protected:
  34. struct Entry
  35. {
  36. std::string name;
  37. ui32 size;
  38. ui32 offset;
  39. const char *data;
  40. };
  41. std::vector<boost::iostreams::mapped_file_source *> mfiles;
  42. 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
  43. public:
  44. std::vector<Entry> entries;
  45. std::map<std::string, int> fimap; // map of file and index
  46. ~CMediaHandler(); //d-tor
  47. void extract(std::string srcfile, std::string dstfile, bool caseSens=true); //saves selected file
  48. const char * extract (std::string srcfile, int & size); //return selecte file data, NULL if file doesn't exist
  49. void extract(int index, std::string dstfile); //saves selected file
  50. const char * extract (int index, int & size); //return selecte file - NIE TESTOWANE
  51. };
  52. class CVidHandler: public CMediaHandler
  53. {
  54. public:
  55. void add_file(std::string fname);
  56. };