Documentation de SFML 2.6.1

Loading...
Searching...
No Matches
sf::FileInputStream Class Reference

Implementation of input stream based on a file. More...

#include <SFML/System/FileInputStream.hpp>

Inheritance diagram for sf::FileInputStream:
sf::InputStream sf::NonCopyable

Public Member Functions

 FileInputStream ()
 Default constructor.
 
virtual ~FileInputStream ()
 Default destructor.
 
bool open (const std::string &filename)
 Open the stream from a file path.
 
virtual Int64 read (void *data, Int64 size)
 Read data from the stream.
 
virtual Int64 seek (Int64 position)
 Change the current reading position.
 
virtual Int64 tell ()
 Get the current reading position in the stream.
 
virtual Int64 getSize ()
 Return the size of the stream.
 

Detailed Description

Implementation of input stream based on a file.

This class is a specialization of InputStream that reads from a file on disk.

It wraps a file in the common InputStream interface and therefore allows to use generic classes or functions that accept such a stream, with a file on disk as the data source.

In addition to the virtual functions inherited from InputStream, FileInputStream adds a function to specify the file to open.

SFML resource classes can usually be loaded directly from a filename, so this class shouldn't be useful to you unless you create your own algorithms that operate on an InputStream.

Usage example:

void process(InputStream& stream);
if (stream.open("some_file.dat"))
process(stream);
Implementation of input stream based on a file.
bool open(const std::string &filename)
Open the stream from a file path.
Abstract class for custom file input streams.

InputStream, MemoryInputStream

Definition at line 55 of file FileInputStream.hpp.

Constructor & Destructor Documentation

◆ FileInputStream()

sf::FileInputStream::FileInputStream ( )

Default constructor.

◆ ~FileInputStream()

virtual sf::FileInputStream::~FileInputStream ( )
virtual

Default destructor.

Member Function Documentation

◆ getSize()

virtual Int64 sf::FileInputStream::getSize ( )
virtual

Return the size of the stream.

Returns
The total number of bytes available in the stream, or -1 on error

Implements sf::InputStream.

◆ open()

bool sf::FileInputStream::open ( const std::string &  filename)

Open the stream from a file path.

Parameters
filenameName of the file to open
Returns
True on success, false on error

◆ read()

virtual Int64 sf::FileInputStream::read ( void *  data,
Int64  size 
)
virtual

Read data from the stream.

After reading, the stream's reading position must be advanced by the amount of bytes read.

Parameters
dataBuffer where to copy the read data
sizeDesired number of bytes to read
Returns
The number of bytes actually read, or -1 on error

Implements sf::InputStream.

◆ seek()

virtual Int64 sf::FileInputStream::seek ( Int64  position)
virtual

Change the current reading position.

Parameters
positionThe position to seek to, from the beginning
Returns
The position actually sought to, or -1 on error

Implements sf::InputStream.

◆ tell()

virtual Int64 sf::FileInputStream::tell ( )
virtual

Get the current reading position in the stream.

Returns
The current position, or -1 on error.

Implements sf::InputStream.


The documentation for this class was generated from the following file: