AssetStream.mm 690 B

123456789101112131415161718192021222324
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2025 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #include <TestFramework.h>
  5. #include <Utils/AssetStream.h>
  6. #include <Utils/Log.h>
  7. #include <Cocoa/Cocoa.h>
  8. String AssetStream::sGetAssetsBasePath()
  9. {
  10. NSBundle *bundle = [NSBundle mainBundle];
  11. String path = [[[bundle resourceURL] path] cStringUsingEncoding: NSUTF8StringEncoding];
  12. path += "/";
  13. return path;
  14. }
  15. AssetStream::AssetStream(const char *inFileName, std::ios_base::openmode inOpenMode) :
  16. mStream((sGetAssetsBasePath() + inFileName).c_str(), inOpenMode)
  17. {
  18. if (!mStream.is_open())
  19. FatalError("Failed to open file %s", inFileName);
  20. }