class EE::System::IOStreamFile

Overview

An implementation for a file system file steam. More…

#include <iostreamfile.hpp>

class IOStreamFile: public EE::System::IOStream {
public:
    // construction

    IOStreamFile(const std::string& path, const std::string& modes = "rb");
    virtual ~IOStreamFile();

    // methods

    static IOStreamFile* New(const std::string& path, const std::string& modes = "rb");
    virtual ios_size read(char* data, ios_size size);
    virtual ios_size write(const char* data, ios_size size);
    virtual ios_size seek(ios_size position);
    virtual ios_size tell();
    virtual ios_size getSize();
    virtual bool isOpen();
    void flush();
    void close();
};

Inherited Members

public:
    // methods

    virtual ios_size read(char* data, ios_size size) = 0;
    virtual ios_size write(const char* data, ios_size size) = 0;
    virtual ios_size seek(ios_size position) = 0;
    virtual ios_size tell() = 0;
    virtual ios_size getSize() = 0;
    virtual bool isOpen() = 0;

Detailed Documentation

An implementation for a file system file steam.

Construction

IOStreamFile(const std::string& path, const std::string& modes = "rb")

Open a file from the file system.

Parameters:

path

File to open from path

modes

The open mode that it will be used for the file ( default read-binary )

Methods

virtual ios_size read(char* data, ios_size size)

Read data from the stream.

Parameters:

data

Buffer where to copy the read data

size

Desired number of bytes to read

Returns:

The number of bytes actually read

virtual ios_size write(const char* data, ios_size size)

Write data to the virtual file.

Parameters:

data

Data to write in the file

size

Size of the data that needs to be writed

virtual ios_size seek(ios_size position)

Change the current reading position.

Parameters:

position

The position to seek to, from the beginning

Returns:

The position actually sought to.

virtual ios_size tell()

Get the current reading position in the stream.

Returns:

The current position, or -1 on error.

virtual ios_size getSize()

Return the size of the stream.

Returns:

The total number of bytes available in the stream

virtual bool isOpen()

Returns:

If the virtual stream file is open

void flush()

Synchronizes the buffer associated with the stream to its controlled output sequence. This effectively means that all unwritten characters in the buffer are written to its controlled output sequence as soon as possible.