CSndHandler.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef __CSNDHANDLER_H__
  2. #define __CSNDHANDLER_H__
  3. #include <vector>
  4. #include <iosfwd>
  5. #include <map>
  6. /*
  7. * CSndHandler.h, part of VCMI engine
  8. *
  9. * Authors: listed in file AUTHORS in main folder
  10. *
  11. * License: GNU General Public License v2.0 or later
  12. * Full text of license available in license.txt file, in main folder
  13. *
  14. */
  15. namespace boost
  16. {
  17. namespace iostreams
  18. {
  19. class mapped_file_source;
  20. }
  21. }
  22. struct MemberFile
  23. {
  24. std::ifstream * ifs;
  25. int length;
  26. };
  27. class CSndHandler
  28. {
  29. private:
  30. struct Entry
  31. {
  32. std::string name;
  33. unsigned int size;
  34. unsigned int offset;
  35. };
  36. inline unsigned int readNormalNr (const unsigned char *p);
  37. boost::iostreams::mapped_file_source *mfile;
  38. public:
  39. std::vector<Entry> entries;
  40. std::map<std::string, int> fimap; // map of wav file and index
  41. ~CSndHandler(); //d-tor
  42. CSndHandler(std::string fname); //c-tor
  43. void extract(std::string srcfile, std::string dstfile, bool caseSens=true); //saves selected file
  44. const char * extract (std::string srcfile, int & size); //return selecte file data, NULL if file doesn't exist
  45. void extract(int index, std::string dstfile); //saves selected file
  46. MemberFile getFile(std::string name);//nie testowane - sprawdzic
  47. const char * extract (int index, int & size); //return selecte file - NIE TESTOWANE
  48. };
  49. class CVidHandler
  50. {
  51. protected:
  52. const int CHUNK;
  53. struct Entry
  54. {
  55. std::string name;
  56. int size, offset, something;
  57. };
  58. std::ifstream file;
  59. int readNormalNr (int pos, int bytCon);
  60. bool opened;
  61. public:
  62. std::vector<Entry> entries;
  63. ~CVidHandler(); //d-tor
  64. CVidHandler(std::string fname); //c-tor
  65. std::ifstream & extract(std::string srcfile);
  66. void extract(std::string srcfile, std::string dstfile, bool caseSens=true); //saves selected file
  67. unsigned char * extract (std::string srcfile, int & size); //return selecte file,
  68. void extract(int index, std::string dstfile); //saves selected file
  69. MemberFile getFile(std::string name); //nie testowane - sprawdzic
  70. };
  71. #endif // __CSNDHANDLER_H__