AssetStream.h 747 B

123456789101112131415161718192021222324252627
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2025 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. JPH_SUPPRESS_WARNINGS_STD_BEGIN
  6. #include <fstream>
  7. JPH_SUPPRESS_WARNINGS_STD_END
  8. /// An istream interface that reads data from a file in the Assets folder
  9. class AssetStream
  10. {
  11. public:
  12. /// Constructor
  13. AssetStream(const char *inFileName, std::ios_base::openmode inOpenMode);
  14. AssetStream(const String &inFileName, std::ios_base::openmode inOpenMode) : AssetStream(inFileName.c_str(), inOpenMode) { }
  15. /// Get the path to the assets folder
  16. static String sGetAssetsBasePath();
  17. /// Get the stream
  18. std::istream & Get() { return mStream; }
  19. private:
  20. std::ifstream mStream;
  21. };