galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
PhysfsStream.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_FS_PHYSFSSTREAM_HPP_
9#define GALAXY_FS_PHYSFSSTREAM_HPP_
10
11#include <string>
12
13#include <SFML/System/InputStream.hpp>
14
15struct PHYSFS_File;
16
17namespace galaxy
18{
19 namespace fs
20 {
24 class PhysfsStream : public sf::InputStream
25 {
26 public:
30 PhysfsStream() noexcept;
31
39 PhysfsStream(const std::string& filename) noexcept;
40
44 virtual ~PhysfsStream() noexcept;
45
51 [[nodiscard]]
52 bool is_open() const noexcept;
53
63 [[maybe_unused]]
64 bool open(const std::string& filename) noexcept;
65
69 void close() noexcept;
70
82 [[nodiscard]]
83 std::optional<std::size_t> read(void* data, std::size_t size) override;
84
92 [[nodiscard]]
93 std::optional<std::size_t> seek(std::size_t position) override;
94
100 [[nodiscard]]
101 std::optional<std::size_t> tell() override;
102
108 [[nodiscard]]
109 std::optional<std::size_t> getSize() override;
110
111 private:
115 PhysfsStream(const PhysfsStream&) = delete;
116
121
126
131
132 private:
136 PHYSFS_File* m_file;
137 };
138 } // namespace fs
139} // namespace galaxy
140#endif
Custom SFML input stream using PhysFS.
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.
PhysfsStream(const PhysfsStream &)=delete
Copy constructor.
PhysfsStream & operator=(PhysfsStream &&)=delete
Move assignment operator.
PhysfsStream(PhysfsStream &&)=delete
Move constructor.
void close() noexcept
Close the open physfs handle.
std::optional< std::size_t > getSize() override
Return the size of the stream.
PhysfsStream & operator=(const PhysfsStream &)=delete
Copy assignment operator.
bool is_open() const noexcept
Is the physfs file open.
Timer.hpp galaxy.
Definition Async.hpp:17