Support large files over 2GB on Windows (#1089)

Backport of 4dcf0b41c6
b01f45e141
https://github.com/taglib/taglib/pull/77

Tested with files larger than 2GB which have been created using

sox -n -r 44100 -C 320 large.mp3 synth 58916 sine 440 channels 2
sox -n -r 44100 -C 0 large.flac synth 25459 sine 440 channels 2
sox -n -r 44100 -C 10 large.ogg synth 229806 sine 440 channels 2
sox -n -r 44100 large.wav synth 6692 sine 440 channels 2
ffmpeg -f lavfi -i "sine=frequency=440:duration=244676" -y large.m4a

The only file which was readable with the tagreader example
before this commit was large.ogg. The problem is that long on
Windows is only 32-bit (also in LLP64 data model of 64-bit
compilation target) and all the file offsets using long are
too small for large files. Now long is replaced by offset_t
(defined to be long long on Windows and off_t on UNIX) for such
cases and some unsigned long are now size_t, which has the
correct size even on Windows.
This commit is contained in:
Urs Fleisch
2020-04-19 11:13:55 +02:00
parent bc915f5dc8
commit ca8c2e07ec
72 changed files with 378 additions and 364 deletions

View File

@ -61,10 +61,10 @@ public:
delete properties;
}
long APELocation;
offset_t APELocation;
long APESize;
long ID3v1Location;
offset_t ID3v1Location;
TagUnion tag;
@ -270,7 +270,7 @@ void WavPack::File::read(bool readProperties)
if(readProperties) {
long streamLength;
offset_t streamLength;
if(d->APELocation >= 0)
streamLength = d->APELocation;

View File

@ -66,14 +66,14 @@ public:
// public members
////////////////////////////////////////////////////////////////////////////////
WavPack::Properties::Properties(const ByteVector &, long, ReadStyle style) :
WavPack::Properties::Properties(const ByteVector &, offset_t, ReadStyle style) :
AudioProperties(style),
d(new PropertiesPrivate())
{
debug("WavPack::Properties::Properties() -- This constructor is no longer used.");
}
WavPack::Properties::Properties(File *file, long streamLength, ReadStyle style) :
WavPack::Properties::Properties(File *file, offset_t streamLength, ReadStyle style) :
AudioProperties(style),
d(new PropertiesPrivate())
{
@ -257,9 +257,9 @@ namespace
} // namespace
void WavPack::Properties::read(File *file, long streamLength)
void WavPack::Properties::read(File *file, offset_t streamLength)
{
long offset = 0;
offset_t offset = 0;
while(true) {
file->seek(offset);
@ -339,9 +339,9 @@ void WavPack::Properties::read(File *file, long streamLength)
}
}
unsigned int WavPack::Properties::seekFinalIndex(File *file, long streamLength)
unsigned int WavPack::Properties::seekFinalIndex(File *file, offset_t streamLength)
{
long offset = streamLength;
offset_t offset = streamLength;
while (offset >= 32) {
offset = file->rfind("wvpk", offset - 4);

View File

@ -30,6 +30,7 @@
#ifndef TAGLIB_WVPROPERTIES_H
#define TAGLIB_WVPROPERTIES_H
#include "tbytevector.h"
#include "taglib_export.h"
#include "audioproperties.h"
@ -58,13 +59,13 @@ namespace TagLib {
* \deprecated This constructor will be dropped in favor of the one below
* in a future version.
*/
TAGLIB_DEPRECATED Properties(const ByteVector &data, long streamLength,
TAGLIB_DEPRECATED Properties(const ByteVector &data, offset_t streamLength,
ReadStyle style = Average);
/*!
* Create an instance of WavPack::Properties.
*/
Properties(File *file, long streamLength, ReadStyle style = Average);
Properties(File *file, offset_t streamLength, ReadStyle style = Average);
/*!
* Destroys this WavPack::Properties instance.
@ -137,8 +138,8 @@ namespace TagLib {
Properties(const Properties &);
Properties &operator=(const Properties &);
void read(File *file, long streamLength);
unsigned int seekFinalIndex(File *file, long streamLength);
void read(File *file, offset_t streamLength);
unsigned int seekFinalIndex(File *file, offset_t streamLength);
class PropertiesPrivate;
PropertiesPrivate *d;