41 if (!filename.empty())
45 m_file = PHYSFS_openRead(filename.c_str());
73 return PHYSFS_readBytes(
m_file, data,
static_cast<PHYSFS_uint32
>(size));
84 if (PHYSFS_seek(
m_file, position))
102 return PHYSFS_tell(
m_file);
113 return PHYSFS_fileLength(
m_file);
bool open(const std::string &filename) noexcept
Open file in physfs.
std::optional< std::size_t > read(void *data, std::size_t size) override
Read data from the stream.
std::optional< std::size_t > seek(std::size_t position) override
Change the current reading position.
PhysfsStream() noexcept
Constructor.
std::optional< std::size_t > tell() override
Get the current reading position in the stream.
virtual ~PhysfsStream() noexcept
Virtual destructor.
PHYSFS_File * m_file
Handle to physfs file data.
void close() noexcept
Close the open physfs handle.
std::optional< std::size_t > getSize() override
Return the size of the stream.
bool is_open() const noexcept
Is the physfs file open.
bool physfs_check(const int code) noexcept
Call a physfs function with error handling and logs a message for you.