CMappedFileLoader.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * CMappedFileLoader.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "ISimpleResourceLoader.h"
  12. #include "CResourceLoader.h"
  13. class CFileInfo;
  14. class CInputStream;
  15. /**
  16. * Class that implements file mapping (aka *nix symbolic links)
  17. * Uses json file as input, content is map:
  18. * "fileA.txt" : "fileB.txt"
  19. * Note that extension is necessary, but used only to determine type
  20. *
  21. * fileA - file which will be replaced
  22. * fileB - file which will be used as replacement
  23. */
  24. class DLL_LINKAGE CMappedFileLoader : public ISimpleResourceLoader
  25. {
  26. public:
  27. /**
  28. * Ctor.
  29. *
  30. * @param config Specifies filesystem configuration
  31. */
  32. explicit CMappedFileLoader(const JsonNode & config);
  33. /// Interface implementation
  34. /// @see ISimpleResourceLoader
  35. std::unique_ptr<CInputStream> load(const std::string & resourceName) const override;
  36. bool existsEntry(const std::string & resourceName) const override;
  37. boost::unordered_map<ResourceID, std::string> getEntries() const override;
  38. std::string getOrigin() const override;
  39. std::string getFullName(const std::string & resourceName) const override;
  40. private:
  41. /** A list of files in this map
  42. * key = ResourceID for resource loader
  43. * value = ResourceID to which file this request will be redirected
  44. */
  45. boost::unordered_map<ResourceID, std::string> fileList;
  46. };