FileResourceArchive.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  3. Permission is hereby granted, free of charge, to any person
  4. obtaining a copy of this software and associated documentation
  5. files (the "Software"), to deal in the Software without
  6. restriction, including without limitation the rights to use,
  7. copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the
  9. Software is furnished to do so, subject to the following
  10. conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  15. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  17. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  18. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #pragma once
  23. #include "Types.h"
  24. #include "ResourceArchive.h"
  25. namespace crown
  26. {
  27. class Filesystem;
  28. class FileStream;
  29. // The header of every compiled resource file.
  30. // KEEP IN SYNC WITH CompiledResource struct in Compiler.h!
  31. struct ResourceHeader
  32. {
  33. uint32_t magic; // Magic number used to identify the file
  34. uint32_t version; // Version of the compiler used to compile the resource
  35. uint32_t name; // Name of the resource (murmur2_32 hash)
  36. uint32_t type; // Type of the resource (murmur2_32 hash)
  37. uint32_t size; // Size of the resource data _not_ including header (in bytes)
  38. };
  39. /// Source of resources
  40. class FileResourceArchive : public ResourceArchive
  41. {
  42. public:
  43. FileResourceArchive(Filesystem& fs);
  44. ~FileResourceArchive();
  45. FileStream* find(ResourceId name);
  46. private:
  47. Filesystem& m_filesystem;
  48. };
  49. } // namespace crown