Loading...
Searching...
No Matches
FileInputStream.hpp
#pragma once
#include "..\..\Platform.hpp"
#include <fstream>
#include "InputStream.hpp"
#include <EASTL/string_view.h>
#ifdef MCE_PLATFORM_WINDOWS
#ifdef INVALID_FILE_SIZE
#undef INVALID_FILE_SIZE
#endif
#endif
namespace mce::io::stream {
class FileInputStream final : public InputStream {
public:
FileInputStream();
~FileInputStream();
//explicit FileInputStream(eastl::string_view file);
bool open(const std::string& file);
bool isOpen() const;
void close();
size_t read(void* buffer, size_t size) override;
size_t seek(size_t position) override;
size_t tell() override;
size_t getSize() override;
static inline constexpr size_t FILE_NOT_FOUND = 0;
static inline constexpr size_t INVALID_FILE_SIZE = ~(0);
static inline constexpr size_t INVALID_FILE_POSITION = ~(0);
private:
#ifdef MCE_PLATFORM_WINDOWS
void* __ptr64 hFile = nullptr;
#elif defined(MCE_PLATFORM_LINUX) || defined(MCE_PLATFORM_MACOS)
std::FILE* file;
#endif
};
}
mce::io::stream::FileInputStream::seek
size_t seek(size_t position) override
Changes the current position the stream is reading.
mce::io::stream::FileInputStream::read
size_t read(void *buffer, size_t size) override
Reads from the input stream.
mce::io::stream::FileInputStream::close
void close()
Closes the file.
mce::io::stream::FileInputStream::getSize
size_t getSize() override
mce::io::stream::FileInputStream::open
bool open(const std::string &file)
Constructs the stream and opens a file.
mce::io::stream::FileInputStream::isOpen
bool isOpen() const
mce::io::stream::FileInputStream::tell
size_t tell() override