Update taglib
This commit is contained in:
parent
2384a42d33
commit
3d13c12cb7
|
@ -339,7 +339,13 @@ UserTextIdentificationFrame::UserTextIdentificationFrame(const String &descripti
|
||||||
|
|
||||||
String UserTextIdentificationFrame::toString() const
|
String UserTextIdentificationFrame::toString() const
|
||||||
{
|
{
|
||||||
return "[" + description() + "] " + fieldList().toString();
|
// first entry is the description itself, drop from values list
|
||||||
|
StringList l = fieldList();
|
||||||
|
for(StringList::Iterator it = l.begin(); it != l.end(); ++it) {
|
||||||
|
l.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return "[" + description() + "] " + l.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
String UserTextIdentificationFrame::description() const
|
String UserTextIdentificationFrame::description() const
|
||||||
|
|
|
@ -231,11 +231,21 @@ void Ogg::FLAC::File::scan()
|
||||||
|
|
||||||
if(!metadataHeader.startsWith("fLaC")) {
|
if(!metadataHeader.startsWith("fLaC")) {
|
||||||
// FLAC 1.1.2+
|
// FLAC 1.1.2+
|
||||||
|
// See https://xiph.org/flac/ogg_mapping.html for the header specification.
|
||||||
|
if(metadataHeader.size() < 13)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(metadataHeader[0] != 0x7f)
|
||||||
|
return;
|
||||||
|
|
||||||
if(metadataHeader.mid(1, 4) != "FLAC")
|
if(metadataHeader.mid(1, 4) != "FLAC")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(metadataHeader[5] != 1)
|
if(metadataHeader[5] != 1 && metadataHeader[6] != 0)
|
||||||
return; // not version 1
|
return; // not version 1.0
|
||||||
|
|
||||||
|
if(metadataHeader.mid(9, 4) != "fLaC")
|
||||||
|
return;
|
||||||
|
|
||||||
metadataHeader = metadataHeader.mid(13);
|
metadataHeader = metadataHeader.mid(13);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,11 @@ namespace
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileHandle openFile(const int fileDescriptor, bool readOnly)
|
||||||
|
{
|
||||||
|
return InvalidFileHandle;
|
||||||
|
}
|
||||||
|
|
||||||
void closeFile(FileHandle file)
|
void closeFile(FileHandle file)
|
||||||
{
|
{
|
||||||
CloseHandle(file);
|
CloseHandle(file);
|
||||||
|
@ -98,6 +103,11 @@ namespace
|
||||||
return fopen(path, readOnly ? "rb" : "rb+");
|
return fopen(path, readOnly ? "rb" : "rb+");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileHandle openFile(const int fileDescriptor, bool readOnly)
|
||||||
|
{
|
||||||
|
return fdopen(fileDescriptor, readOnly ? "rb" : "rb+");
|
||||||
|
}
|
||||||
|
|
||||||
void closeFile(FileHandle file)
|
void closeFile(FileHandle file)
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
@ -149,13 +159,28 @@ FileStream::FileStream(FileName fileName, bool openReadOnly)
|
||||||
d->file = openFile(fileName, true);
|
d->file = openFile(fileName, true);
|
||||||
|
|
||||||
if(d->file == InvalidFileHandle)
|
if(d->file == InvalidFileHandle)
|
||||||
{
|
|
||||||
# ifdef _WIN32
|
# ifdef _WIN32
|
||||||
debug("Could not open file " + fileName.toString());
|
debug("Could not open file " + fileName.toString());
|
||||||
# else
|
# else
|
||||||
debug("Could not open file " + String(static_cast<const char *>(d->name)));
|
debug("Could not open file " + String(static_cast<const char *>(d->name)));
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileStream::FileStream(int fileDescriptor, bool openReadOnly)
|
||||||
|
: d(new FileStreamPrivate(""))
|
||||||
|
{
|
||||||
|
// First try with read / write mode, if that fails, fall back to read only.
|
||||||
|
|
||||||
|
if(!openReadOnly)
|
||||||
|
d->file = openFile(fileDescriptor, false);
|
||||||
|
|
||||||
|
if(d->file != InvalidFileHandle)
|
||||||
|
d->readOnly = false;
|
||||||
|
else
|
||||||
|
d->file = openFile(fileDescriptor, true);
|
||||||
|
|
||||||
|
if(d->file == InvalidFileHandle)
|
||||||
|
debug("Could not open file using file descriptor");
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream::~FileStream()
|
FileStream::~FileStream()
|
||||||
|
@ -255,8 +280,7 @@ void FileStream::insert(const ByteVector &data, unsigned long start, unsigned lo
|
||||||
ByteVector buffer = data;
|
ByteVector buffer = data;
|
||||||
ByteVector aboutToOverwrite(static_cast<unsigned int>(bufferLength));
|
ByteVector aboutToOverwrite(static_cast<unsigned int>(bufferLength));
|
||||||
|
|
||||||
while(true)
|
while(true) {
|
||||||
{
|
|
||||||
// Seek to the current read position and read the data that we're about
|
// Seek to the current read position and read the data that we're about
|
||||||
// to overwrite. Appropriately increment the readPosition.
|
// to overwrite. Appropriately increment the readPosition.
|
||||||
|
|
||||||
|
@ -304,8 +328,7 @@ void FileStream::removeBlock(unsigned long start, unsigned long length)
|
||||||
|
|
||||||
ByteVector buffer(static_cast<unsigned int>(bufferLength));
|
ByteVector buffer(static_cast<unsigned int>(bufferLength));
|
||||||
|
|
||||||
for(unsigned int bytesRead = -1; bytesRead != 0;)
|
for(unsigned int bytesRead = -1; bytesRead != 0;) {
|
||||||
{
|
|
||||||
seek(readPosition);
|
seek(readPosition);
|
||||||
bytesRead = static_cast<unsigned int>(readFile(d->file, buffer));
|
bytesRead = static_cast<unsigned int>(readFile(d->file, buffer));
|
||||||
readPosition += bytesRead;
|
readPosition += bytesRead;
|
||||||
|
@ -401,7 +424,8 @@ long FileStream::tell() const
|
||||||
const LARGE_INTEGER zero = {};
|
const LARGE_INTEGER zero = {};
|
||||||
LARGE_INTEGER position;
|
LARGE_INTEGER position;
|
||||||
|
|
||||||
if(SetFilePointerEx(d->file, zero, &position, FILE_CURRENT) && position.QuadPart <= LONG_MAX) {
|
if(SetFilePointerEx(d->file, zero, &position, FILE_CURRENT) &&
|
||||||
|
position.QuadPart <= LONG_MAX) {
|
||||||
return static_cast<long>(position.QuadPart);
|
return static_cast<long>(position.QuadPart);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -470,9 +494,8 @@ void FileStream::truncate(long length)
|
||||||
#else
|
#else
|
||||||
|
|
||||||
const int error = ftruncate(fileno(d->file), length);
|
const int error = ftruncate(fileno(d->file), length);
|
||||||
if(error != 0) {
|
if(error != 0)
|
||||||
debug("FileStream::truncate() -- Coundn't truncate the file.");
|
debug("FileStream::truncate() -- Coundn't truncate the file.");
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,11 @@ namespace TagLib {
|
||||||
*/
|
*/
|
||||||
FileStream(FileName file, bool openReadOnly = false);
|
FileStream(FileName file, bool openReadOnly = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a File object and opens the \a file using file descriptor.
|
||||||
|
*/
|
||||||
|
FileStream(int fileDescriptor, bool openReadOnly = false);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this FileStream instance.
|
* Destroys this FileStream instance.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue