42 lines
724 B
C++
42 lines
724 B
C++
// Copyright 2024 The DMBMX2Tools Authors
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
#include <base/io/Stream.hpp>
|
|
|
|
namespace dmtools::io {
|
|
|
|
/// A I/O stream using libc FILE*.
|
|
struct FileStream : public Stream {
|
|
enum class OpenMode : u8 {
|
|
Read,
|
|
ReadWrite
|
|
};
|
|
|
|
virtual ~FileStream();
|
|
|
|
bool Open(const std::string& path, OpenMode mode);
|
|
|
|
void Flush() override;
|
|
|
|
void Close();
|
|
|
|
StreamDiff ReadSome(u8* buffer, usize length) override;
|
|
|
|
StreamDiff WriteSome(const u8* buffer, usize length) override;
|
|
|
|
StreamDiff Seek(StreamDiff where, StreamSeekDirection dir) override;
|
|
|
|
StreamDiff Tell() const override;
|
|
|
|
bool Ok() const override;
|
|
|
|
bool Eof() const override;
|
|
|
|
|
|
private:
|
|
void* file{};
|
|
};
|
|
|
|
}
|