26 m_file = PHYSFS_openRead(
path.string().c_str());
57 m_file = PHYSFS_openRead(
path.string().c_str());
75 m_error = !PHYSFS_close(m_file);
104 const PHYSFS_sint64
length = PHYSFS_fileLength(m_file);
107 return static_cast<std::size_t
>(
length);
115 const PHYSFS_sint64
offset = PHYSFS_tell(m_file);
122 return static_cast<std::size_t
>(
offset);
127 if (!PHYSFS_seek(m_file,
static_cast<PHYSFS_uint64
>(
offset)))
133 m_eof = (PHYSFS_eof(m_file) != 0);
138 const PHYSFS_sint64
status = PHYSFS_readBytes(m_file, data,
count);
142 if (
status < 0 || !PHYSFS_eof(m_file))
150 return static_cast<std::size_t
>(
status);
160 PHYSFS_uint16* data16 =
reinterpret_cast<PHYSFS_uint16*
>(data);
162 for (std::size_t i = 0; i <
count; ++i)
164 if (!PHYSFS_readULE16(m_file, data16))
167 m_eof = (PHYSFS_eof(m_file) != 0);
179 PHYSFS_uint16* data16 =
reinterpret_cast<PHYSFS_uint16*
>(data);
181 for (std::size_t i = 0; i <
count; ++i)
183 if (!PHYSFS_readUBE16(m_file, data16))
186 m_eof = (PHYSFS_eof(m_file) != 0);
198 PHYSFS_uint32* data32 =
reinterpret_cast<PHYSFS_uint32*
>(data);
200 for (std::size_t i = 0; i <
count; ++i)
202 if (!PHYSFS_readULE32(m_file, data32))
205 m_eof = (PHYSFS_eof(m_file) != 0);
217 PHYSFS_uint32* data32 =
reinterpret_cast<PHYSFS_uint32*
>(data);
219 for (std::size_t i = 0; i <
count; ++i)
221 if (!PHYSFS_readUBE32(m_file, data32))
224 m_eof = (PHYSFS_eof(m_file) != 0);
236 PHYSFS_uint64* data64 =
reinterpret_cast<PHYSFS_uint64*
>(data);
238 for (std::size_t i = 0; i <
count; ++i)
240 if (!PHYSFS_readULE64(m_file, data64))
243 m_eof = (PHYSFS_eof(m_file) != 0);
255 PHYSFS_uint64* data64 =
reinterpret_cast<PHYSFS_uint64*
>(data);
257 for (std::size_t i = 0; i <
count; ++i)
259 if (!PHYSFS_readUBE64(m_file, data64))
262 m_eof = (PHYSFS_eof(m_file) != 0);
An exception of this type is thrown when an error occurs during deserialization.
physfs_deserialize_context() noexcept=default
Constructs a PhysicsFS deserialize context.
std::size_t read16_be(std::byte *data, std::size_t count) noexcept(false) override
Reads 16-bit (word) big-endian data.
void close() noexcept
Closes the associated file using PhysicsFS.
std::size_t read32_be(std::byte *data, std::size_t count) noexcept(false) override
Reads 32-bit (double word) big-endian data.
void open(const std::filesystem::path &path) noexcept(false)
Opens a file using PhysicsFS and associates it with the deserialize context.
const std::filesystem::path & path() const noexcept override
Returns the path associated with this deserialize context.
void seek(std::size_t offset) override
Seeks to a position in the file.
std::size_t tell() const override
Returns the offsets from the start of the file to the current position, in bytes.
std::size_t read8(std::byte *data, std::size_t count) noexcept(false) override
Reads 8-bit (byte) data.
std::size_t read32_le(std::byte *data, std::size_t count) noexcept(false) override
Reads 32-bit (double word) little-endian data.
std::size_t read64_le(std::byte *data, std::size_t count) noexcept(false) override
Reads 64-bit (quad word) little-endian data.
bool error() const noexcept override
Returns true if an error occured during a read operation or initialization, false otherwise.
bool eof() const noexcept override
Returns true if the end of a file was reached.
std::size_t size() const noexcept override
Returns the size of the file, in bytes.
std::size_t read16_le(std::byte *data, std::size_t count) noexcept(false) override
Reads 16-bit (word) little-endian data.
std::size_t read64_be(std::byte *data, std::size_t count) noexcept(false) override
Reads 64-bit (quad word) big-endian data.
virtual ~physfs_deserialize_context()
Destructs a PhysicsFS deserialize context, internally closing a file using PhysicsFS.
bool is_open() const noexcept
Returns true if the PhysicsFS file associated with this deserialize context is open,...
status
Behavior tree node return status enumerations.
constexpr int count(T x) noexcept
Returns the number of set bits in a value, known as a population count or Hamming weight.
T length(const quaternion< T > &q)
Calculates the length of a quaternion.
T offset(T longitude)
Calculates the UTC offset at a given longitude.