#pragma once #include #include #include #ifdef WITH_UNREAL #include "HAL/PlatformFileManager.h" #include "GenericPlatform/GenericPlatformFile.h" #endif class SweepstoreFileHandle { private: std::string path; #ifdef WITH_UNREAL IFileHandle* unrealHandle; #else std::unique_ptr stream; #endif public: SweepstoreFileHandle(const std::string& p, std::ios::openmode mode = std::ios::in | std::ios::out | std::ios::binary); const std::string& getPath() const { return path; } #ifndef WITH_UNREAL std::fstream& getStream() { return *stream; } const std::fstream& getStream() const { return *stream; } // Smart pointer-like interface std::fstream* operator->() { return stream.get(); } const std::fstream* operator->() const { return stream.get(); } std::fstream& operator*() { return *stream; } const std::fstream& operator*() const { return *stream; } #endif bool isOpen() const; void close(); // Windows-compatible I/O wrappers void readSeek(std::streampos pos, std::ios::seekdir dir = std::ios::beg); void writeSeek(std::streampos pos, std::ios::seekdir dir = std::ios::beg); void readBytes(char* buffer, std::streamsize size); void writeBytes(const char* buffer, std::streamsize size); SweepstoreFileHandle(SweepstoreFileHandle&&) noexcept = default; SweepstoreFileHandle& operator=(SweepstoreFileHandle&&) noexcept = default; SweepstoreFileHandle(const SweepstoreFileHandle&) = delete; SweepstoreFileHandle& operator=(const SweepstoreFileHandle&) = delete; ~SweepstoreFileHandle() { close(); } };