CommonUtilities.cpp 924 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "CommonUtilities.h"
  9. namespace SimulationInterfaces::Utils
  10. {
  11. const char* const ProductAssetPrefix = "product_asset:///";
  12. AZStd::string RelPathToUri(AZStd::string_view relPath)
  13. {
  14. AZStd::string uri = relPath;
  15. AZStd::replace(uri.begin(), uri.end(), '\\', '/');
  16. uri.insert(0, ProductAssetPrefix);
  17. return uri;
  18. }
  19. AZStd::string UriToRelPath(AZStd::string_view uri)
  20. {
  21. if (uri.starts_with(ProductAssetPrefix))
  22. {
  23. const AZStd::string_view productAssetPrefix{ ProductAssetPrefix };
  24. return uri.substr(productAssetPrefix.length());
  25. }
  26. return {};
  27. }
  28. } // namespace SimulationInterfaces::Utils