TagLib::FileStream Class Reference

I/O stream with data from a file. More...

`#include <tfilestream.h>`

Inheritance diagram for TagLib::FileStream:
[legend]
Collaboration diagram for TagLib::FileStream:
[legend]

## Public Member Functions

| FileStream (FileName fileName, bool openReadOnly=false)
| FileStream (int fileDescriptor, bool openReadOnly=false)
| ~FileStream () override
| FileStream (const FileStream &)=delete
FileStream & | operator= (const FileStream &)=delete
FileName | name () const override
ByteVector | readBlock (size_t length) override
void | writeBlock (const ByteVector &data) override
void | insert (const ByteVector &data, offset_t start=0, size_t replace=0) override
void | removeBlock (offset_t start=0, size_t length=0) override
bool | readOnly () const override
bool | isOpen () const override
void | seek (offset_t offset, Position p=Beginning) override
void | clear () override
offset_t | tell () const override
offset_t | length () override
void | truncate (offset_t length) override
Public Member Functions inherited from TagLib::IOStream
| IOStream ()
virtual | ~IOStream ()
| IOStream (const IOStream &)=delete
IOStream & | operator= (const IOStream &)=delete

## Static Protected Member Functions

static unsigned int | bufferSize ()

## Additional Inherited Members

Public Types inherited from TagLib::IOStream
enum | Position { Beginning , Current , End }

## Detailed Description

I/O stream with data from a file.

## Constructor & Destructor Documentation

## FileStream() [1/3]

TagLib::FileStream::FileStream | ( | FileName | fileName,
|  | bool | openReadOnly = false )

Construct a FileStream object and open the fileName. fileName should be a C-string in the local file system encoding.

Referenced by FileStream(), and operator=().

## FileStream() [2/3]

TagLib::FileStream::FileStream | ( | int | fileDescriptor,
|  | bool | openReadOnly = false )

Construct a FileStream object using an existing fileDescriptor.

## ~FileStream()

TagLib::FileStream::~FileStream | ( |  | ) |

override

Destroys this FileStream instance.

## FileStream() [3/3]

TagLib::FileStream::FileStream | ( | const FileStream & |  | ) |

delete

References FileStream().

## Member Function Documentation

## bufferSize()

unsigned int TagLib::FileStream::bufferSize | ( |  | ) |

static protected

Returns the buffer size that is used for internal buffering.

References TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE.

## clear()

void TagLib::FileStream::clear | ( |  | ) |

override virtual

Reset the end-of-file and error flags on the file.

Reimplemented from TagLib::IOStream.

## insert()

void TagLib::FileStream::insert | ( | const ByteVector & | data,
|  | offset_t | start = 0,
|  | size_t | replace = 0 )

override virtual

Insert data at position start in the file overwriting replace bytes of the original content.

Note
  This method is slow since it requires rewriting all of the file after the insertion point.

Implements TagLib::IOStream.

## isOpen()

bool TagLib::FileStream::isOpen | ( |  | ) | const

override virtual

Since the file can currently only be opened as an argument to the constructor (sort-of by design), this returns if that open succeeded.

Implements TagLib::IOStream.

## length()

offset_t TagLib::FileStream::length | ( |  | ) |

override virtual

Returns the length of the file.

Implements TagLib::IOStream.

Referenced by readBlock(), removeBlock(), and truncate().

## name()

FileName TagLib::FileStream::name | ( |  | ) | const

override virtual

Returns the file name in the local file system encoding.

Implements TagLib::IOStream.

## operator=()

FileStream & TagLib::FileStream::operator= | ( | const FileStream & |  | ) |

delete

References FileStream().

## readBlock()

ByteVector TagLib::FileStream::readBlock | ( | size_t | length | ) |

override virtual

Reads a block of size length at the current get pointer.

Implements TagLib::IOStream.

References length().

## readOnly()

bool TagLib::FileStream::readOnly | ( |  | ) | const

override virtual

Returns `true` if the file is read only (or if the file can not be opened).

Implements TagLib::IOStream.

## removeBlock()

void TagLib::FileStream::removeBlock | ( | offset_t | start = 0,
|  | size_t | length = 0 )

override virtual

Removes a block of the file starting a start and continuing for length bytes.

Note
  This method is slow since it involves rewriting all of the file after the removed portion.

Implements TagLib::IOStream.

References length().

## seek()

void TagLib::FileStream::seek | ( | offset_t | offset,
|  | Position | p = Beginning )

override virtual

Move the I/O pointer to offset in the file from position p. This defaults to seeking from the beginning of the file.

See also
  Position

Implements TagLib::IOStream.

References TagLib::IOStream::Beginning.

## tell()

offset_t TagLib::FileStream::tell | ( |  | ) | const

override virtual

Returns the current offset within the file.

Implements TagLib::IOStream.

## truncate()

void TagLib::FileStream::truncate | ( | offset_t | length | ) |

override virtual

Truncates the file to a length.

Implements TagLib::IOStream.

References length().

## writeBlock()

void TagLib::FileStream::writeBlock | ( | const ByteVector & | data | ) |

override virtual

Attempts to write the block data at the current get pointer. If the file is currently only opened read only – i.e. readOnly() returns `true` – this attempts to reopen the file in read/write mode.

Note
  This should be used instead of using the streaming output operator for a ByteVector. And even this function is significantly slower than doing output with a char[].

Implements TagLib::IOStream.

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

- tfilestream.h