simple_resource.cpp 757 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2012-2025 Daniele Bartolini et al.
  3. * SPDX-License-Identifier: MIT
  4. */
  5. #include "core/filesystem/file_memory.inl"
  6. #include "core/memory/allocator.h"
  7. #include "resource/simple_resource.h"
  8. namespace crown
  9. {
  10. namespace simple_resource
  11. {
  12. void *load(File &file, Allocator &a)
  13. {
  14. const u32 file_size = file.size();
  15. void *data = a.allocate(file_size, 16);
  16. file.read(data, file_size);
  17. return data;
  18. }
  19. void unload(Allocator &a, void *data)
  20. {
  21. a.deallocate(data);
  22. }
  23. void *load_from_bundle(File &file, Allocator &a)
  24. {
  25. CE_UNUSED(a);
  26. return (void *)((FileMemory &)file)._memory;
  27. }
  28. void unload_from_bundle(Allocator &a, void *data)
  29. {
  30. CE_UNUSED_2(a, data);
  31. return;
  32. }
  33. } // namespace simple_resource
  34. } // namespace crown