A file class with some useful methods for tag manipulation. More...
#include <tfile.h>
Public Types | |
enum | Position { Beginning , Current , End } |
enum | StripTags { StripNone , StripOthers } |
enum | DuplicateTags { Duplicate , DoNotDuplicate } |
Public Member Functions | |
virtual | ~File () |
FileName | name () const |
virtual Tag * | tag () const =0 |
PropertyMap | properties () const |
void | removeUnsupportedProperties (const StringList &properties) |
PropertyMap | setProperties (const PropertyMap &properties) |
virtual AudioProperties * | audioProperties () const =0 |
virtual bool | save ()=0 |
ByteVector | readBlock (unsigned long length) |
void | writeBlock (const ByteVector &data) |
long | find (const ByteVector &pattern, long fromOffset=0, const ByteVector &before=ByteVector()) |
long | rfind (const ByteVector &pattern, long fromOffset=0, const ByteVector &before=ByteVector()) |
void | insert (const ByteVector &data, unsigned long start=0, unsigned long replace=0) |
void | removeBlock (unsigned long start=0, unsigned long 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 TAGLIB_DEPRECATED bool | isReadable (const char *file) |
static TAGLIB_DEPRECATED bool | isWritable (const char *name) |
Protected Member Functions | |
File (FileName file) | |
File (IOStream *stream) | |
void | setValid (bool valid) |
void | truncate (long length) |
Static Protected Member Functions | |
static unsigned int | bufferSize () |
A file class with some useful methods for tag manipulation.
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 |
Destroys this File instance.
Reimplemented in TagLib::XM::File, TagLib::WavPack::File, TagLib::TrueAudio::File, TagLib::S3M::File, TagLib::RIFF::WAV::File, TagLib::RIFF::File, TagLib::RIFF::AIFF::File, TagLib::Ogg::Vorbis::File, TagLib::Ogg::Speex::File, TagLib::Ogg::Opus::File, TagLib::Ogg::File, TagLib::Ogg::FLAC::File, TagLib::MPEG::File, TagLib::MPC::File, TagLib::MP4::File, TagLib::Mod::File, TagLib::IT::File, TagLib::FLAC::File, TagLib::ASF::File, and TagLib::APE::File.
|
protected |
Construct a File object and opens the file. file should be a be a C-string in the local file system encoding.
|
protected |
|
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::XM::File, TagLib::WavPack::File, TagLib::TrueAudio::File, TagLib::S3M::File, TagLib::RIFF::WAV::File, TagLib::RIFF::AIFF::File, TagLib::Ogg::Vorbis::File, TagLib::Ogg::Speex::File, TagLib::Ogg::Opus::File, TagLib::Ogg::FLAC::File, TagLib::MPEG::File, TagLib::MPC::File, TagLib::MP4::File, TagLib::Mod::File, TagLib::IT::File, TagLib::FLAC::File, TagLib::ASF::File, and TagLib::APE::File.
|
staticprotected |
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() |
||
) |
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 sync frame.
Searching starts at fromOffset, which defaults to the beginning of the file.
void TagLib::File::insert | ( | const ByteVector & | data, |
unsigned long | start = 0 , |
||
unsigned long | 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 |
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 readable.
|
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.
PropertyMap TagLib::File::properties | ( | ) | const |
Exports the tags of the file as dictionary mapping (human readable) tag names (uppercase Strings) to StringLists of tag values. Calls the according specialization in the File subclasses. For each metadata object of the file that could not be parsed into the PropertyMap format, the returned map's unsupportedData() list will contain one entry identifying that object (e.g. the frame type for ID3v2 tags). Use removeUnsupportedProperties() to remove (a subset of) them. For files that contain more than one tag (e.g. an MP3 with both an ID3v1 and an ID3v2 tag) only the most "modern" one will be exported (ID3v2 in this case). BIC: Will be made virtual in future releases.
ByteVector TagLib::File::readBlock | ( | unsigned long | 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).
void TagLib::File::removeBlock | ( | unsigned long | start = 0 , |
unsigned long | length = 0 |
||
) |
Removes a block of the file starting a start and continuing for length bytes.
void TagLib::File::removeUnsupportedProperties | ( | const StringList & | properties | ) |
Removes unsupported properties, or a subset of them, from the file's metadata. The parameter properties must contain only entries from properties().unsupportedData(). BIC: Will be mad virtual in future releases.
long TagLib::File::rfind | ( | const ByteVector & | pattern, |
long | fromOffset = 0 , |
||
const ByteVector & | before = ByteVector() |
||
) |
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 sync 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.
|
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::XM::File, TagLib::WavPack::File, TagLib::TrueAudio::File, TagLib::S3M::File, TagLib::RIFF::WAV::File, TagLib::RIFF::AIFF::File, TagLib::Ogg::Vorbis::File, TagLib::Ogg::Speex::File, TagLib::Ogg::Opus::File, TagLib::Ogg::File, TagLib::Ogg::FLAC::File, TagLib::MPEG::File, TagLib::MPC::File, TagLib::MP4::File, TagLib::Mod::File, TagLib::IT::File, TagLib::FLAC::File, TagLib::ASF::File, and TagLib::APE::File.
Move the I/O pointer to offset in the file from position p. This defaults to seeking from the beginning of the file.
PropertyMap TagLib::File::setProperties | ( | const PropertyMap & | properties | ) |
Sets the tags of this File to those specified in properties. Calls the according specialization method in the subclasses of File to do the translation into the format-specific details. If some value(s) could not be written imported to the specific metadata format, the returned PropertyMap will contain those value(s). Otherwise it will be empty, indicating that no problems occurred. With file types that support several tag formats (for instance, MP3 files can have ID3v1, ID3v2, and APEv2 tags), this function will create the most appropriate one (ID3v2 for MP3 files). Older formats will be updated as well, if they exist, but won't be taken into account for the return value of this function. See the documentation of the subclass implementations for detailed descriptions. BIC: will become pure virtual in the future
|
protected |
Marks the file as valid or invalid.
|
pure virtual |
Returns a pointer to this file's tag. This should be reimplemented in the concrete subclasses.
Implemented in TagLib::XM::File, TagLib::WavPack::File, TagLib::TrueAudio::File, TagLib::S3M::File, TagLib::RIFF::WAV::File, TagLib::RIFF::AIFF::File, TagLib::Ogg::Vorbis::File, TagLib::Ogg::Speex::File, TagLib::Ogg::Opus::File, TagLib::Ogg::FLAC::File, TagLib::MPEG::File, TagLib::MPC::File, TagLib::MP4::File, TagLib::Mod::File, TagLib::IT::File, TagLib::FLAC::File, TagLib::ASF::File, and TagLib::APE::File.
long TagLib::File::tell | ( | ) | const |
Returns the current offset within the file.
|
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.