mirror of
https://github.com/encounter/aurora.git
synced 2026-07-09 18:19:33 -07:00
d61a1824ac
* 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
36 lines
946 B
C++
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
|