Enhance Windows file handling with improved sync and error checking in read/write operations

This commit is contained in:
ImBenji
2025-12-02 15:12:32 +00:00
parent ad6a740a73
commit 7adca647a6
2 changed files with 38 additions and 4 deletions

View File

@@ -39,10 +39,26 @@ public:
void close();
// Windows-compatible I/O wrappers
#if defined(_WIN32) || defined(WITH_UNREAL)
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);
#else
// Inline for non-Windows to avoid overhead
inline void readSeek(std::streampos pos, std::ios::seekdir dir = std::ios::beg) {
stream->seekg(pos, dir);
}
inline void writeSeek(std::streampos pos, std::ios::seekdir dir = std::ios::beg) {
stream->seekp(pos, dir);
}
inline void readBytes(char* buffer, std::streamsize size) {
stream->read(buffer, size);
}
inline void writeBytes(const char* buffer, std::streamsize size) {
stream->write(buffer, size);
}
#endif
SweepstoreFileHandle(SweepstoreFileHandle&&) noexcept = default;
SweepstoreFileHandle& operator=(SweepstoreFileHandle&&) noexcept = default;