MCPcopy Create free account
hub / github.com/RobLoach/raylib-cpp / FileData

Class FileData

include/FileData.hpp:12–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10namespace raylib {
11
12class FileData {
13public:
14 FileData() = default;
15 FileData(const FileData&) = delete;
16 FileData(FileData&& other) noexcept : data(other.data), bytesRead(other.bytesRead) {
17 other.data = nullptr;
18 other.bytesRead = 0;
19 }
20 FileData& operator=(const FileData&) = delete;
21 FileData& operator=(FileData&& other) noexcept {
22 std::swap(data, other.data);
23 std::swap(bytesRead, other.bytesRead);
24 return *this;
25 }
26 ~FileData() { Unload(); }
27
28 explicit FileData(const std::string& fileName) { Load(fileName); }
29
30 GETTER(const unsigned char*, Data, data)
31 GETTER(int, BytesRead, bytesRead)
32
33 void Load(const std::string& fileName) { Load(fileName.c_str()); }
34 void Load(const char* fileName) {
35 Unload();
36 data = ::LoadFileData(fileName, &bytesRead);
37 }
38
39 void Unload() {
40 if (data != nullptr) {
41 ::UnloadFileData(data);
42 data = nullptr;
43 bytesRead = 0;
44 }
45 }
46private:
47 unsigned char* data{nullptr};
48 int bytesRead{0};
49};
50
51} // namespace raylib
52

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected