Enhance Windows file handling with improved sync and error checking in read/write operations
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user