resource_id.cpp 744 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (c) 2012-2025 Daniele Bartolini et al.
  3. * SPDX-License-Identifier: MIT
  4. */
  5. #include "config.h"
  6. #include "core/filesystem/path.h"
  7. #include "core/memory/temp_allocator.inl"
  8. #include "core/strings/dynamic_string.inl"
  9. #include "core/strings/string_id.inl"
  10. #include "resource/resource_id.inl"
  11. namespace crown
  12. {
  13. ResourceId resource_id(const char *path)
  14. {
  15. const char *type = resource_type(path);
  16. const u32 name_len = resource_name_length(type, path);
  17. return resource_id(type, strlen32(type), path, name_len);
  18. }
  19. void destination_path(DynamicString &path, ResourceId id)
  20. {
  21. TempAllocator128 ta;
  22. DynamicString id_hex(ta);
  23. id_hex.from_string_id(id);
  24. path::join(path, CROWN_DATA_DIRECTORY, id_hex.c_str());
  25. }
  26. } // namespace crown