![]() |
|
#include <tfile.h>
Public Types | |
enum | Position { Beginning, Current, End } |
Public Member Functions | |
virtual | ~File () |
FileName | name () const |
virtual Tag * | tag () const =0 |
virtual AudioProperties * | audioProperties () const =0 |
virtual bool | save ()=0 |
ByteVector | readBlock (ulong length) |
void | writeBlock (const ByteVector &data) |
long | find (const ByteVector &pattern, long fromOffset=0, const ByteVector &before=ByteVector::null) |
long | rfind (const ByteVector &pattern, long fromOffset=0, const ByteVector &before=ByteVector::null) |
void | insert (const ByteVector &data, ulong start=0, ulong replace=0) |
void | removeBlock (ulong start=0, ulong length=0) |
bool | readOnly () const |
bool | isOpen () const |
bool | isValid () const |
void | seek (long offset, Position p=Beginning) |
void | clear () |
long | tell () const |
long | length () |
Static Public Member Functions | |
static bool | isReadable (const char *file) |
static bool | isWritable (const char *name) |
Protected Member Functions | |
File (FileName file) | |
void | setValid (bool valid) |
void | truncate (long length) |
Static Protected Member Functions | |
static uint | bufferSize () |
This class is a basic file class with some methods that are particularly useful for tag editors. It has methods to take advantage of ByteVector and a binary search method for finding patterns in a file.
virtual TagLib::File::~File | ( | ) | [virtual] |
Destroys this File instance.
Reimplemented in TagLib::ASF::File, TagLib::FLAC::File, TagLib::MP4::File, TagLib::MPC::File, TagLib::MPEG::File, TagLib::Ogg::FLAC::File, TagLib::Ogg::File, TagLib::Ogg::Speex::File, TagLib::Ogg::Vorbis::File, TagLib::RIFF::AIFF::File, TagLib::RIFF::File, TagLib::RIFF::WAV::File, TagLib::TrueAudio::File, and TagLib::WavPack::File.
TagLib::File::File | ( | FileName | file | ) | [protected] |
Construct a File object and opens the file. file should be a be a C-string in the local file system encoding.
Reimplemented in TagLib::Ogg::File.
virtual AudioProperties* TagLib::File::audioProperties | ( | ) | const [pure virtual] |
Returns a pointer to this file's audio properties. This should be reimplemented in the concrete subclasses. If no audio properties were read then this will return a null pointer.
Implemented in TagLib::ASF::File, TagLib::FLAC::File, TagLib::MP4::File, TagLib::MPC::File, TagLib::MPEG::File, TagLib::Ogg::FLAC::File, TagLib::Ogg::Speex::File, TagLib::Ogg::Vorbis::File, TagLib::RIFF::AIFF::File, TagLib::RIFF::WAV::File, TagLib::TrueAudio::File, and TagLib::WavPack::File.
static uint TagLib::File::bufferSize | ( | ) | [static, protected] |
Returns the buffer size that is used for internal buffering.
void TagLib::File::clear | ( | ) |
Reset the end-of-file and error flags on the file.
long TagLib::File::find | ( | const ByteVector & | pattern, | |
long | fromOffset = 0 , |
|||
const ByteVector & | before = ByteVector::null | |||
) |
Returns the offset in the file that pattern occurs at or -1 if it can not be found. If before is set, the search will only continue until the pattern before is found. This is useful for tagging purposes to search for a tag before the synch frame.
Searching starts at fromOffset, which defaults to the beginning of the file.
void TagLib::File::insert | ( | const ByteVector & | data, | |
ulong | start = 0 , |
|||
ulong | replace = 0 | |||
) |
Insert data at position start in the file overwriting replace bytes of the original content.
bool TagLib::File::isOpen | ( | ) | const |
Since the file can currently only be opened as an argument to the constructor (sort-of by design), this returns if that open succeeded.
static bool TagLib::File::isReadable | ( | const char * | file | ) | [static] |
Returns true if file can be opened for reading. If the file does not exist, this will return false.
bool TagLib::File::isValid | ( | ) | const |
Returns true if the file is open and readble.
static bool TagLib::File::isWritable | ( | const char * | name | ) | [static] |
Returns true if file can be opened for writing.
long TagLib::File::length | ( | ) |
Returns the length of the file.
FileName TagLib::File::name | ( | ) | const |
Returns the file name in the local file system encoding.
ByteVector TagLib::File::readBlock | ( | ulong | length | ) |
Reads a block of size length at the current get pointer.
bool TagLib::File::readOnly | ( | ) | const |
Returns true if the file is read only (or if the file can not be opened).
Removes a block of the file starting a start and continuing for length bytes.
long TagLib::File::rfind | ( | const ByteVector & | pattern, | |
long | fromOffset = 0 , |
|||
const ByteVector & | before = ByteVector::null | |||
) |
Returns the offset in the file that pattern occurs at or -1 if it can not be found. If before is set, the search will only continue until the pattern before is found. This is useful for tagging purposes to search for a tag before the synch frame.
Searching starts at fromOffset and proceeds from the that point to the beginning of the file and defaults to the end of the file.
virtual bool TagLib::File::save | ( | ) | [pure virtual] |
Save the file and its associated tags. This should be reimplemented in the concrete subclasses. Returns true if the save succeeds.
Implemented in TagLib::ASF::File, TagLib::FLAC::File, TagLib::MP4::File, TagLib::MPC::File, TagLib::MPEG::File, TagLib::Ogg::FLAC::File, TagLib::Ogg::File, TagLib::Ogg::Speex::File, TagLib::Ogg::Vorbis::File, TagLib::RIFF::AIFF::File, TagLib::RIFF::WAV::File, TagLib::TrueAudio::File, and TagLib::WavPack::File.
void TagLib::File::seek | ( | long | offset, | |
Position | p = Beginning | |||
) |
Move the I/O pointer to offset in the file from position p. This defaults to seeking from the beginning of the file.
void TagLib::File::setValid | ( | bool | valid | ) | [protected] |
virtual Tag* TagLib::File::tag | ( | ) | const [pure virtual] |
Returns a pointer to this file's tag. This should be reimplemented in the concrete subclasses.
Implemented in TagLib::ASF::File, TagLib::FLAC::File, TagLib::MP4::File, TagLib::MPC::File, TagLib::MPEG::File, TagLib::Ogg::FLAC::File, TagLib::Ogg::Speex::File, TagLib::Ogg::Vorbis::File, TagLib::RIFF::AIFF::File, TagLib::RIFF::WAV::File, TagLib::TrueAudio::File, and TagLib::WavPack::File.
long TagLib::File::tell | ( | ) | const |
Returns the current offset within the file.
void TagLib::File::truncate | ( | long | length | ) | [protected] |
Truncates the file to a length.
void TagLib::File::writeBlock | ( | const ByteVector & | data | ) |
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.