Nebula
Loading...
Searching...
No Matches
filestream.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
12#include "io/stream.h"
13#include "io/fswrapper.h"
14
15//------------------------------------------------------------------------------
16namespace IO
17{
18class FileStream : public Stream
19{
21public:
23 FileStream();
25 virtual ~FileStream();
27 virtual bool CanRead() const override;
29 virtual bool CanWrite() const override;
31 virtual bool CanSeek() const override;
33 virtual bool CanBeMapped() const override;
35 virtual Size GetSize() const override;
37 virtual Position GetPosition() const override;
39 virtual bool Open() override;
41 virtual void Close() override;
43 virtual void Write(const void* ptr, Size numBytes) override;
45 virtual Size Read(void* ptr, Size numBytes) override;
47 virtual void Seek(Offset offset, SeekOrigin origin) override;
49 virtual void Flush() override;
51 virtual bool Eof() const override;
53 virtual void* Map() override;
55 virtual void Unmap() override;
57 virtual void* MemoryMap() override;
59 virtual void MemoryUnmap() override;
60
61protected:
62 FSWrapper::Handle handle;
63 FSWrapper::Handle mapHandle;
65};
66
67} // namespace IO
68//------------------------------------------------------------------------------
A stream to which offers read/write access to filesystem files.
Definition filestream.h:19
virtual ~FileStream()
destructor
Definition filestream.cc:30
virtual Position GetPosition() const override
get the current position of the read/write cursor
Definition filestream.cc:89
virtual void Unmap() override
unmap stream
Definition filestream.cc:228
virtual bool CanSeek() const override
supports seeking?
Definition filestream.cc:60
virtual Size GetSize() const override
get the size of the stream in bytes
Definition filestream.cc:79
virtual bool CanWrite() const override
supports writing?
Definition filestream.cc:51
virtual void * Map() override
map stream to memory
Definition filestream.cc:210
virtual Size Read(void *ptr, Size numBytes) override
directly read from the stream
Definition filestream.cc:160
__DeclareClass(FileStream)
virtual bool Eof() const override
return true if end-of-stream reached
Definition filestream.cc:198
FSWrapper::Handle mapHandle
Definition filestream.h:63
FileStream()
constructor
Definition filestream.cc:19
FSWrapper::Handle handle
Definition filestream.h:62
virtual bool Open() override
open the stream
Definition filestream.cc:99
virtual bool CanRead() const override
supports reading?
Definition filestream.cc:42
void * mappedContent
Definition filestream.h:64
virtual void Close() override
close the stream
Definition filestream.cc:123
virtual void Seek(Offset offset, SeekOrigin origin) override
seek in stream
Definition filestream.cc:174
virtual void * MemoryMap() override
memory map stream to memory
Definition filestream.cc:240
virtual void Flush() override
flush unsaved data
Definition filestream.cc:186
virtual bool CanBeMapped() const override
supports memory mapping (read-only)?
Definition filestream.cc:70
virtual void MemoryUnmap() override
unmap memory stream
Definition filestream.cc:252
Offers an abstract interface for read/write access to a sequence of bytes.
Definition stream.h:28
SeekOrigin
seek origins
Definition stream.h:54
int64_t Offset
Definition stream.h:33
int64_t Position
typedefs
Definition stream.h:32
int64_t Size
Definition stream.h:34
Instances of wrapped stream classes.
Definition orientation.cc:10
@ Write
Definition filewatcher.h:47