Library: Foundation
Package: Streams
Header: Poco/FileStream.h
Description
The base class for FileInputStream and FileOutputStream.
This class is needed to ensure the correct initialization order of the stream buffer and base classes.
Files are always opened in binary mode, a text mode with CR-LF translation is not supported. Thus, the file is always opened as if the std::ios::binary flag was specified. Use an InputLineEndingConverter or OutputLineEndingConverter if you require CR-LF translation.
On Windows platforms, UTF-8 encoded Unicode paths are correctly handled.
Inheritance
Direct Base Classes: std::ios
All Base Classes: std::ios
Known Derived Classes: FileInputStream, FileOutputStream, FileStream
Member Summary
Member Functions: close, flushToDisk, nativeHandle, open, openHandle, rdbuf, size
Types Aliases
NativeHandle
using NativeHandle = FileStreamBuf::NativeHandle;
Constructors
FileIOS
FileIOS();
Creates the basic stream.
Destructor
~FileIOS
~FileIOS() override;
Destroys the stream.
Member Functions
close
void close();
Closes the file stream.
If, for an output stream, the close operation fails (because the contents of the stream buffer cannot synced back to the filesystem), the bad bit is set in the stream state.
flushToDisk
void flushToDisk();
Forces buffered data to be written to the disk
nativeHandle
NativeHandle nativeHandle() const;
Returns native file descriptor handle
open
virtual void open(
const std::string & path,
std::ios::openmode mode
);
Opens the file specified by path, using the given mode.
Throws a FileException (or a similar exception) if the file does not exist or is not accessible for other reasons and a new file cannot be created.
openHandle
void openHandle(
NativeHandle handle,
std::ios::openmode mode
);
Takes ownership of the handle.
rdbuf
FileStreamBuf * rdbuf();
Returns a pointer to the underlying streambuf.
size
UInt64 size() const;
Returns file size
Variables
_buf
FileStreamBuf _buf;