class Poco::FileIOS

Overview

The base class for FileInputStream and FileOutputStream. More…

#include <FileStream.h>

class FileIOS: public ios
{
public:
    // construction

    FileIOS(std::ios::openmode defaultMode);

    // methods

    void
    open(
        const std::string& path,
        std::ios::openmode mode
        );

    void
    close();

    FileStreamBuf*
    rdbuf();

protected:
    // fields

    FileStreamBuf _buf;
    std::ios::openmode _defaultMode;
};

// direct descendants

class FileInputStream;
class FileOutputStream;
class FileStream;

Detailed Documentation

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, if POCO_WIN32_UTF8 is #define’d, UTF-8 encoded Unicode paths are correctly handled.

Construction

FileIOS(std::ios::openmode defaultMode)

Creates the basic stream.

Methods

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.

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.

FileStreamBuf*
rdbuf()

Returns a pointer to the underlying streambuf.