|
| FileStreamImpl (const char *path_, AccessMode accessMode_, OpenMode openMode_, MemoryResource *memRes_) |
|
void | open () override |
| Open access to the stream. More...
|
|
void | close () override |
| Close access to the stream. More...
|
|
std::uint64_t | tell () override |
| Get the current position in the stream. More...
|
|
void | seek (std::uint64_t position) override |
| Set the current position in the stream. More...
|
|
std::uint64_t | size () override |
| Obtain size of stream in bytes. More...
|
|
std::size_t | read (char *destination, std::size_t size) override |
| Read bytes from stream into the given buffer. More...
|
|
std::size_t | read (Writable *destination, std::size_t size) override |
| Read bytes from this stream into the given stream. More...
|
|
std::size_t | write (const char *source, std::size_t size) override |
| Writes bytes from the given buffer to the stream. More...
|
|
std::size_t | write (Readable *source, std::size_t size) override |
| Writes bytes from the given stream to this stream. More...
|
|
MemoryResource * | getMemoryResource () |
|
| FileStream ()=default |
|
| ~FileStream () override |
|
| FileStream (const FileStream &)=delete |
|
FileStream & | operator= (const FileStream &)=delete |
|
| FileStream (FileStream &&)=default |
|
FileStream & | operator= (FileStream &&)=default |
|
virtual | ~BoundedIOStream () |
|
virtual void | open ()=0 |
| Open access to the stream. More...
|
|
virtual void | close ()=0 |
| Close access to the stream. More...
|
|
virtual std::size_t | read (char *destination, std::size_t size)=0 |
| Read bytes from stream into the given buffer. More...
|
|
virtual std::size_t | read (Writable *destination, std::size_t size)=0 |
| Read bytes from this stream into the given stream. More...
|
|
virtual std::size_t | write (const char *source, std::size_t size)=0 |
| Writes bytes from the given buffer to the stream. More...
|
|
virtual std::size_t | write (Readable *source, std::size_t size)=0 |
| Writes bytes from the given stream to this stream. More...
|
|
virtual std::uint64_t | tell ()=0 |
| Get the current position in the stream. More...
|
|
virtual void | seek (std::uint64_t position)=0 |
| Set the current position in the stream. More...
|
|
virtual std::uint64_t | size ()=0 |
| Obtain size of stream in bytes. More...
|
|
void trio::FileStreamImpl::open |
( |
| ) |
|
|
overridevirtual |
Open access to the stream.
Implements trio::Openable.
69 {
73 return;
74 }
75
76 std::ios_base::openmode flags{};
80 flags |= std::ios_base::ate;
81
84 }
85
89 return;
90 }
93}
static void set(StatusCode status)
Definition: Provider.cpp:33
static void reset()
Definition: Provider.cpp:21
static const sc::StatusCode OpenError
Definition: Stream.h:19
static const sc::StatusCode AlreadyOpenError
Definition: Stream.h:22
void seek(std::uint64_t position) override
Set the current position in the stream.
Definition: FileStreamImpl.cpp:103
StreamStatus status
Definition: FileStreamImpl.h:49
void ensureFileExistsStd(const NativeCharacter *path)
Definition: FileStreamImpl.cpp:36
std::enable_if< std::is_enum< TEnum >::value, bool >::type contains(TEnum lhs, TEnum rhs)
Definition: trio/utils/ScopedEnumEx.h:57
References trio::BoundedIOStream::AlreadyOpenError, trio::Binary, trio::contains(), trio::anonymous_namespace{FileStreamImpl.cpp}::ensureFileExistsStd(), file, fileAccessMode, fileOpenMode, filePath, fileSize, trio::BoundedIOStream::OpenError, trio::Read, trio::ReadWrite, sc::StatusProvider::reset(), seek(), sc::StatusProvider::set(), status, and trio::Write.
std::size_t trio::FileStreamImpl::write |
( |
const char * |
source, |
|
|
std::size_t |
size |
|
) |
| |
|
overridevirtual |
Writes bytes from the given buffer to the stream.
- Parameters
-
source | Source buffer from which the data is going to be written to the stream. |
size | Number of bytes to write to the stream. |
- Returns
- Number of bytes written.
Implements trio::Writable.
153 {
156 return 0ul;
157 }
158
159 const auto preWritePos =
file.tellp();
160 file.write(source,
static_cast<std::streamsize
>(
size));
161 const auto postWritePos =
file.tellp();
162
165 } else {
167 }
168
169 return (postWritePos > preWritePos ? static_cast<std::size_t>(postWritePos - preWritePos) : 0ul);
170}
static const sc::StatusCode WriteError
Definition: Stream.h:21
References trio::contains(), file, fileAccessMode, filePath, fileSize, sc::StatusProvider::set(), size(), status, trio::Write, and trio::BoundedIOStream::WriteError.
std::size_t trio::FileStreamImpl::write |
( |
Readable * |
source, |
|
|
std::size_t |
size |
|
) |
| |
|
overridevirtual |
Writes bytes from the given stream to this stream.
- Parameters
-
source | Source stream from which the data is going to be written into this stream. |
size | Number of bytes to write to the stream. |
- Returns
- Number of bytes written.
Implements trio::Writable.
172 {
175 return 0ul;
176 }
177
178 const auto preWritePos =
file.tellp();
179
185 }
186 source->read(buffer,
size);
187 file.write(buffer,
static_cast<std::streamsize
>(
size));
188
189 const auto postWritePos =
file.tellp();
190
193 } else {
195 }
196
197 return (postWritePos > preWritePos ? static_cast<std::size_t>(postWritePos - preWritePos) : 0ul);
198}
References trio::anonymous_namespace{FileStreamImpl.cpp}::bufferSize, trio::contains(), file, fileAccessMode, filePath, fileSize, trio::Readable::read(), sc::StatusProvider::set(), size(), status, trio::Write, and trio::BoundedIOStream::WriteError.