Files
aurora/lib/card/FileIO.hpp
T
Pieter-Jan Briers d61a1824ac Fix handling of Unicode paths on Windows (#166)
* Fix handling of Unicode paths on Windows

I love C++

* Reduce the amount of reinterpret_casts

* Okay? Don't commit the file CLion? Why not?

* Fix texture replacements too
2026-05-10 10:54:59 -06:00

36 lines
946 B
C++

#pragma once
#include <cstddef>
#include <string>
#include <filesystem>
#include <SDL3/SDL_iostream.h>
namespace aurora::card {
class FileIO {
std::string m_path;
bool m_ready = false;
bool isReady() const { return m_ready && !m_path.empty(); };
public:
FileIO() = default;
explicit FileIO(const std::filesystem::path& filename, bool truncate = false);
~FileIO() = default;
FileIO(FileIO&& other) noexcept;
FileIO& operator=(FileIO&& other) noexcept;
FileIO(const FileIO& other) = delete;
FileIO& operator=(const FileIO& other) = delete;
static SDL_IOStream* fileOpen(const std::string& path, const char* mode) {return path.empty() ? nullptr : SDL_IOFromFile(path.c_str(), mode);}
bool fileRead(void* buf, size_t length, off_t offset);
bool fileWrite(const void* buf, size_t length, off_t offset);
size_t fileSize() const;
bool deleteFile();
explicit operator bool() const;
};
} // namespace aurora::card