Warning, /multimedia/kid3/packaging/patches/taglib-1.13.1-win00-large_file.patch is written in an unsupported language. File is not indexed.

0001 From 8569e324ba11ca61d908f5fdf4b234586dd69fa9 Mon Sep 17 00:00:00 2001
0002 From: Urs Fleisch <ufleisch@users.sourceforge.net>
0003 Date: Sun, 19 Apr 2020 11:13:55 +0200
0004 Subject: Support large files over 2GB
0005 
0006 Backport of 4dcf0b41c687292e7b1263a679921c157ae2c22a
0007 b01f45e141afa6a89aea319a2783f177e202fa1d
0008 https://github.com/taglib/taglib/pull/77
0009 
0010 diff --git a/taglib/ape/apefile.cpp b/taglib/ape/apefile.cpp
0011 index 07057054..4d797d1e 100644
0012 --- a/taglib/ape/apefile.cpp
0013 +++ b/taglib/ape/apefile.cpp
0014 @@ -69,13 +69,13 @@ public:
0015      delete properties;
0016    }
0017  
0018 -  long APELocation;
0019 +  offset_t APELocation;
0020    long APESize;
0021  
0022 -  long ID3v1Location;
0023 +  offset_t ID3v1Location;
0024  
0025    ID3v2::Header *ID3v2Header;
0026 -  long ID3v2Location;
0027 +  offset_t ID3v2Location;
0028    long ID3v2Size;
0029  
0030    TagUnion tag;
0031 @@ -292,7 +292,7 @@ void APE::File::read(bool readProperties)
0032  
0033    if(readProperties) {
0034  
0035 -    long streamLength;
0036 +    offset_t streamLength;
0037  
0038      if(d->APELocation >= 0)
0039        streamLength = d->APELocation;
0040 diff --git a/taglib/ape/apeproperties.cpp b/taglib/ape/apeproperties.cpp
0041 index ef99ad04..fe724c30 100644
0042 --- a/taglib/ape/apeproperties.cpp
0043 +++ b/taglib/ape/apeproperties.cpp
0044 @@ -70,7 +70,7 @@ APE::Properties::Properties(File *, ReadStyle style) :
0045    debug("APE::Properties::Properties() -- This constructor is no longer used.");
0046  }
0047  
0048 -APE::Properties::Properties(File *file, long streamLength, ReadStyle style) :
0049 +APE::Properties::Properties(File *file, offset_t streamLength, ReadStyle style) :
0050    AudioProperties(style),
0051    d(new PropertiesPrivate())
0052  {
0053 @@ -142,10 +142,10 @@ namespace
0054    }
0055  } // namespace
0056  
0057 -void APE::Properties::read(File *file, long streamLength)
0058 +void APE::Properties::read(File *file, offset_t streamLength)
0059  {
0060    // First, we assume that the file pointer is set at the first descriptor.
0061 -  long offset = file->tell();
0062 +  offset_t offset = file->tell();
0063    int version = headerVersion(file->readBlock(6));
0064  
0065    // Next, we look for the descriptor.
0066 diff --git a/taglib/ape/apeproperties.h b/taglib/ape/apeproperties.h
0067 index 8c67481a..d7ddaa30 100644
0068 --- a/taglib/ape/apeproperties.h
0069 +++ b/taglib/ape/apeproperties.h
0070 @@ -61,7 +61,7 @@ namespace TagLib {
0071         * Create an instance of APE::Properties with the data read from the
0072         * APE::File \a file.
0073         */
0074 -      Properties(File *file, long streamLength, ReadStyle style = Average);
0075 +      Properties(File *file, offset_t streamLength, ReadStyle style = Average);
0076  
0077        /*!
0078         * Destroys this APE::Properties instance.
0079 @@ -129,7 +129,7 @@ namespace TagLib {
0080        Properties(const Properties &);
0081        Properties &operator=(const Properties &);
0082  
0083 -      void read(File *file, long streamLength);
0084 +      void read(File *file, offset_t streamLength);
0085  
0086        void analyzeCurrent(File *file);
0087        void analyzeOld(File *file);
0088 diff --git a/taglib/ape/apetag.cpp b/taglib/ape/apetag.cpp
0089 index 4235f73e..3cf91b2e 100644
0090 --- a/taglib/ape/apetag.cpp
0091 +++ b/taglib/ape/apetag.cpp
0092 @@ -80,7 +80,7 @@ public:
0093      footerLocation(0) {}
0094  
0095    File *file;
0096 -  long footerLocation;
0097 +  offset_t footerLocation;
0098  
0099    Footer footer;
0100    ItemListMap itemListMap;
0101 @@ -95,7 +95,7 @@ APE::Tag::Tag() :
0102  {
0103  }
0104  
0105 -APE::Tag::Tag(TagLib::File *file, long footerLocation) :
0106 +APE::Tag::Tag(TagLib::File *file, offset_t footerLocation) :
0107    d(new TagPrivate())
0108  {
0109    d->file = file;
0110 diff --git a/taglib/ape/apetag.h b/taglib/ape/apetag.h
0111 index 01504291..4829379a 100644
0112 --- a/taglib/ape/apetag.h
0113 +++ b/taglib/ape/apetag.h
0114 @@ -66,7 +66,7 @@ namespace TagLib {
0115         * Create an APE tag and parse the data in \a file with APE footer at
0116         * \a tagOffset.
0117         */
0118 -      Tag(TagLib::File *file, long footerLocation);
0119 +      Tag(TagLib::File *file, offset_t footerLocation);
0120  
0121        /*!
0122         * Destroys this Tag instance.
0123 diff --git a/taglib/flac/flacfile.cpp b/taglib/flac/flacfile.cpp
0124 index a71d688b..8ff99d89 100644
0125 --- a/taglib/flac/flacfile.cpp
0126 +++ b/taglib/flac/flacfile.cpp
0127 @@ -79,10 +79,10 @@ public:
0128    }
0129  
0130    const ID3v2::FrameFactory *ID3v2FrameFactory;
0131 -  long ID3v2Location;
0132 +  offset_t ID3v2Location;
0133    long ID3v2OriginalSize;
0134  
0135 -  long ID3v1Location;
0136 +  offset_t ID3v1Location;
0137  
0138    TagUnion tag;
0139  
0140 @@ -90,8 +90,8 @@ public:
0141    ByteVector xiphCommentData;
0142    BlockList blocks;
0143  
0144 -  long flacStart;
0145 -  long streamStart;
0146 +  offset_t flacStart;
0147 +  offset_t streamStart;
0148    bool scanned;
0149  };
0150  
0151 @@ -219,8 +219,8 @@ bool FLAC::File::save()
0152  
0153    // Compute the amount of padding, and append that to data.
0154  
0155 -  long originalLength = d->streamStart - d->flacStart;
0156 -  long paddingLength = originalLength - data.size() - 4;
0157 +  offset_t originalLength = d->streamStart - d->flacStart;
0158 +  offset_t paddingLength = originalLength - data.size() - 4;
0159  
0160    if(paddingLength <= 0) {
0161      paddingLength = MinPaddingLength;
0162 @@ -228,9 +228,9 @@ bool FLAC::File::save()
0163    else {
0164      // Padding won't increase beyond 1% of the file size or 1MB.
0165  
0166 -    long threshold = length() / 100;
0167 -    threshold = std::max(threshold, MinPaddingLength);
0168 -    threshold = std::min(threshold, MaxPaddingLegnth);
0169 +    offset_t threshold = length() / 100;
0170 +    threshold = std::max<offset_t>(threshold, MinPaddingLength);
0171 +    threshold = std::min<offset_t>(threshold, MaxPaddingLegnth);
0172  
0173      if(paddingLength > threshold)
0174        paddingLength = MinPaddingLength;
0175 @@ -341,7 +341,7 @@ ByteVector FLAC::File::streamInfoData()
0176    return ByteVector();
0177  }
0178  
0179 -long FLAC::File::streamLength()
0180 +offset_t FLAC::File::streamLength()
0181  {
0182    debug("FLAC::File::streamLength() -- This function is obsolete. Returning zero.");
0183    return 0;
0184 @@ -456,7 +456,7 @@ void FLAC::File::read(bool readProperties)
0185  
0186      const ByteVector infoData = d->blocks.front()->render();
0187  
0188 -    long streamLength;
0189 +    offset_t streamLength;
0190  
0191      if(d->ID3v1Location >= 0)
0192        streamLength = d->ID3v1Location - d->streamStart;
0193 @@ -477,7 +477,7 @@ void FLAC::File::scan()
0194    if(!isValid())
0195      return;
0196  
0197 -  long nextBlockOffset;
0198 +  offset_t nextBlockOffset;
0199  
0200    if(d->ID3v2Location >= 0)
0201      nextBlockOffset = find("fLaC", d->ID3v2Location + d->ID3v2OriginalSize);
0202 diff --git a/taglib/flac/flacfile.h b/taglib/flac/flacfile.h
0203 index a43c68c6..05803767 100644
0204 --- a/taglib/flac/flacfile.h
0205 +++ b/taglib/flac/flacfile.h
0206 @@ -256,7 +256,7 @@ namespace TagLib {
0207         *
0208         * \deprecated Always returns zero.
0209         */
0210 -      TAGLIB_DEPRECATED long streamLength();  // BIC: remove
0211 +      TAGLIB_DEPRECATED offset_t streamLength();  // BIC: remove
0212  
0213        /*!
0214         * Returns a list of pictures attached to the FLAC file.
0215 diff --git a/taglib/flac/flacproperties.cpp b/taglib/flac/flacproperties.cpp
0216 index b947f039..a798940a 100644
0217 --- a/taglib/flac/flacproperties.cpp
0218 +++ b/taglib/flac/flacproperties.cpp
0219 @@ -55,7 +55,7 @@ public:
0220  // public members
0221  ////////////////////////////////////////////////////////////////////////////////
0222  
0223 -FLAC::Properties::Properties(ByteVector data, long streamLength, ReadStyle style) :
0224 +FLAC::Properties::Properties(ByteVector data, offset_t streamLength, ReadStyle style) :
0225    AudioProperties(style),
0226    d(new PropertiesPrivate())
0227  {
0228 @@ -128,7 +128,7 @@ ByteVector FLAC::Properties::signature() const
0229  // private members
0230  ////////////////////////////////////////////////////////////////////////////////
0231  
0232 -void FLAC::Properties::read(const ByteVector &data, long streamLength)
0233 +void FLAC::Properties::read(const ByteVector &data, offset_t streamLength)
0234  {
0235    if(data.size() < 18) {
0236      debug("FLAC::Properties::read() - FLAC properties must contain at least 18 bytes.");
0237 diff --git a/taglib/flac/flacproperties.h b/taglib/flac/flacproperties.h
0238 index e58f9aea..c47e4493 100644
0239 --- a/taglib/flac/flacproperties.h
0240 +++ b/taglib/flac/flacproperties.h
0241 @@ -50,7 +50,7 @@ namespace TagLib {
0242         * ByteVector \a data.
0243         */
0244         // BIC: switch to const reference
0245 -      Properties(ByteVector data, long streamLength, ReadStyle style = Average);
0246 +      Properties(ByteVector data, offset_t streamLength, ReadStyle style = Average);
0247  
0248        /*!
0249         * Create an instance of FLAC::Properties with the data read from the
0250 @@ -137,7 +137,7 @@ namespace TagLib {
0251        Properties(const Properties &);
0252        Properties &operator=(const Properties &);
0253  
0254 -      void read(const ByteVector &data, long streamLength);
0255 +      void read(const ByteVector &data, offset_t streamLength);
0256  
0257        class PropertiesPrivate;
0258        PropertiesPrivate *d;
0259 diff --git a/taglib/mp4/mp4atom.cpp b/taglib/mp4/mp4atom.cpp
0260 index 02e90f9c..edd615f2 100644
0261 --- a/taglib/mp4/mp4atom.cpp
0262 +++ b/taglib/mp4/mp4atom.cpp
0263 @@ -93,7 +93,7 @@ MP4::Atom::Atom(File *file)
0264    for(int i = 0; i < numContainers; i++) {
0265      if(name == containers[i]) {
0266        if(name == "meta") {
0267 -        long posAfterMeta = file->tell();
0268 +        offset_t posAfterMeta = file->tell();
0269          ByteVector nextSize = file->readBlock(8).mid(4, 4);
0270          static const char *const metaChildrenNames[] = {
0271              "hdlr", "ilst", "mhdr", "ctry", "lang"
0272 @@ -182,7 +182,7 @@ MP4::Atoms::Atoms(File *file)
0273    atoms.setAutoDelete(true);
0274  
0275    file->seek(0, File::End);
0276 -  long end = file->tell();
0277 +  offset_t end = file->tell();
0278    file->seek(0);
0279    while(file->tell() + 8 <= end) {
0280      MP4::Atom *atom = new MP4::Atom(file);
0281 diff --git a/taglib/mp4/mp4atom.h b/taglib/mp4/mp4atom.h
0282 index 0a0669e4..48873cc9 100644
0283 --- a/taglib/mp4/mp4atom.h
0284 +++ b/taglib/mp4/mp4atom.h
0285 @@ -80,8 +80,8 @@ namespace TagLib {
0286        Atom *find(const char *name1, const char *name2 = 0, const char *name3 = 0, const char *name4 = 0);
0287        bool path(AtomList &path, const char *name1, const char *name2 = 0, const char *name3 = 0);
0288        AtomList findall(const char *name, bool recursive = false);
0289 -      long offset;
0290 -      long length;
0291 +      offset_t offset;
0292 +      offset_t length;
0293        TagLib::ByteVector name;
0294        AtomList children;
0295      private:
0296 diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp
0297 index df628800..fa2ed147 100644
0298 --- a/taglib/mp4/mp4properties.cpp
0299 +++ b/taglib/mp4/mp4properties.cpp
0300 @@ -38,7 +38,7 @@ namespace
0301    {
0302      long long totalLength = 0;
0303      for(MP4::AtomList::ConstIterator it = list.begin(); it != list.end(); ++it) {
0304 -      long length = (*it)->length;
0305 +      offset_t length = (*it)->length;
0306        if(length == 0)
0307          return 0; // for safety, see checkValid() in mp4file.cpp
0308  
0309 diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp
0310 index 946c789d..5ba83474 100644
0311 --- a/taglib/mp4/mp4tag.cpp
0312 +++ b/taglib/mp4/mp4tag.cpp
0313 @@ -583,7 +583,7 @@ MP4::Tag::updateParents(const AtomList &path, long delta, int ignore)
0314  }
0315  
0316  void
0317 -MP4::Tag::updateOffsets(long delta, long offset)
0318 +MP4::Tag::updateOffsets(long delta, offset_t offset)
0319  {
0320    MP4::Atom *moov = d->atoms->find("moov");
0321    if(moov) {
0322 @@ -667,7 +667,7 @@ MP4::Tag::saveNew(ByteVector data)
0323      data = renderAtom("udta", data);
0324    }
0325  
0326 -  long offset = path.back()->offset + 8;
0327 +  offset_t offset = path.back()->offset + 8;
0328    d->file->insert(data, offset, 0);
0329  
0330    updateParents(path, data.size());
0331 @@ -685,8 +685,8 @@ MP4::Tag::saveExisting(ByteVector data, const AtomList &path)
0332    AtomList::ConstIterator it = path.end();
0333  
0334    MP4::Atom *ilst = *(--it);
0335 -  long offset = ilst->offset;
0336 -  long length = ilst->length;
0337 +  offset_t offset = ilst->offset;
0338 +  offset_t length = ilst->length;
0339  
0340    MP4::Atom *meta = *(--it);
0341    AtomList::ConstIterator index = meta->children.find(ilst);
0342 diff --git a/taglib/mp4/mp4tag.h b/taglib/mp4/mp4tag.h
0343 index 42b3d4b3..a4f78cf1 100644
0344 --- a/taglib/mp4/mp4tag.h
0345 +++ b/taglib/mp4/mp4tag.h
0346 @@ -149,7 +149,7 @@ namespace TagLib {
0347          ByteVector renderCovr(const ByteVector &name, const Item &item) const;
0348  
0349          void updateParents(const AtomList &path, long delta, int ignore = 0);
0350 -        void updateOffsets(long delta, long offset);
0351 +        void updateOffsets(long delta, offset_t offset);
0352  
0353          void saveNew(ByteVector data);
0354          void saveExisting(ByteVector data, const AtomList &path);
0355 diff --git a/taglib/mpc/mpcfile.cpp b/taglib/mpc/mpcfile.cpp
0356 index 4e955875..7070649b 100644
0357 --- a/taglib/mpc/mpcfile.cpp
0358 +++ b/taglib/mpc/mpcfile.cpp
0359 @@ -61,13 +61,13 @@ public:
0360      delete properties;
0361    }
0362  
0363 -  long APELocation;
0364 +  offset_t APELocation;
0365    long APESize;
0366  
0367 -  long ID3v1Location;
0368 +  offset_t ID3v1Location;
0369  
0370    ID3v2::Header *ID3v2Header;
0371 -  long ID3v2Location;
0372 +  offset_t ID3v2Location;
0373    long ID3v2Size;
0374  
0375    TagUnion tag;
0376 @@ -310,7 +310,7 @@ void MPC::File::read(bool readProperties)
0377  
0378    if(readProperties) {
0379  
0380 -    long streamLength;
0381 +    offset_t streamLength;
0382  
0383      if(d->APELocation >= 0)
0384        streamLength = d->APELocation;
0385 diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp
0386 index effaabed..724e5c7d 100644
0387 --- a/taglib/mpc/mpcproperties.cpp
0388 +++ b/taglib/mpc/mpcproperties.cpp
0389 @@ -66,14 +66,14 @@ public:
0390  // public members
0391  ////////////////////////////////////////////////////////////////////////////////
0392  
0393 -MPC::Properties::Properties(const ByteVector &data, long streamLength, ReadStyle style) :
0394 +MPC::Properties::Properties(const ByteVector &data, offset_t streamLength, ReadStyle style) :
0395    AudioProperties(style),
0396    d(new PropertiesPrivate())
0397  {
0398    readSV7(data, streamLength);
0399  }
0400  
0401 -MPC::Properties::Properties(File *file, long streamLength, ReadStyle style) :
0402 +MPC::Properties::Properties(File *file, offset_t streamLength, ReadStyle style) :
0403    AudioProperties(style),
0404    d(new PropertiesPrivate())
0405  {
0406 @@ -203,7 +203,7 @@ namespace
0407    const unsigned short sftable [8] = { 44100, 48000, 37800, 32000, 0, 0, 0, 0 };
0408  }  // namespace
0409  
0410 -void MPC::Properties::readSV8(File *file, long streamLength)
0411 +void MPC::Properties::readSV8(File *file, offset_t streamLength)
0412  {
0413    bool readSH = false, readRG = false;
0414  
0415 @@ -295,7 +295,7 @@ void MPC::Properties::readSV8(File *file, long streamLength)
0416    }
0417  }
0418  
0419 -void MPC::Properties::readSV7(const ByteVector &data, long streamLength)
0420 +void MPC::Properties::readSV7(const ByteVector &data, offset_t streamLength)
0421  {
0422    if(data.startsWith("MP+")) {
0423      if(data.size() < 4)
0424 diff --git a/taglib/mpc/mpcproperties.h b/taglib/mpc/mpcproperties.h
0425 index 1db925d6..2c692735 100644
0426 --- a/taglib/mpc/mpcproperties.h
0427 +++ b/taglib/mpc/mpcproperties.h
0428 @@ -53,13 +53,13 @@ namespace TagLib {
0429         *
0430         * This constructor is deprecated. It only works for MPC version up to 7.
0431         */
0432 -      Properties(const ByteVector &data, long streamLength, ReadStyle style = Average);
0433 +      Properties(const ByteVector &data, offset_t streamLength, ReadStyle style = Average);
0434  
0435        /*!
0436         * Create an instance of MPC::Properties with the data read directly
0437         * from a MPC::File.
0438         */
0439 -      Properties(File *file, long streamLength, ReadStyle style = Average);
0440 +      Properties(File *file, offset_t streamLength, ReadStyle style = Average);
0441  
0442        /*!
0443         * Destroys this MPC::Properties instance.
0444 @@ -146,8 +146,8 @@ namespace TagLib {
0445        Properties(const Properties &);
0446        Properties &operator=(const Properties &);
0447  
0448 -      void readSV7(const ByteVector &data, long streamLength);
0449 -      void readSV8(File *file, long streamLength);
0450 +      void readSV7(const ByteVector &data, offset_t streamLength);
0451 +      void readSV8(File *file, offset_t streamLength);
0452  
0453        class PropertiesPrivate;
0454        PropertiesPrivate *d;
0455 diff --git a/taglib/mpeg/id3v1/id3v1tag.cpp b/taglib/mpeg/id3v1/id3v1tag.cpp
0456 index 667adfa6..bdf1b9a8 100644
0457 --- a/taglib/mpeg/id3v1/id3v1tag.cpp
0458 +++ b/taglib/mpeg/id3v1/id3v1tag.cpp
0459 @@ -48,7 +48,7 @@ public:
0460      genre(255) {}
0461  
0462    File *file;
0463 -  long tagOffset;
0464 +  offset_t tagOffset;
0465  
0466    String title;
0467    String artist;
0468 @@ -88,7 +88,7 @@ ID3v1::Tag::Tag() :
0469  {
0470  }
0471  
0472 -ID3v1::Tag::Tag(File *file, long tagOffset) :
0473 +ID3v1::Tag::Tag(File *file, offset_t tagOffset) :
0474    d(new TagPrivate())
0475  {
0476    d->file = file;
0477 diff --git a/taglib/mpeg/id3v1/id3v1tag.h b/taglib/mpeg/id3v1/id3v1tag.h
0478 index 5803312f..acdda66c 100644
0479 --- a/taglib/mpeg/id3v1/id3v1tag.h
0480 +++ b/taglib/mpeg/id3v1/id3v1tag.h
0481 @@ -114,7 +114,7 @@ namespace TagLib {
0482         * Create an ID3v1 tag and parse the data in \a file starting at
0483         * \a tagOffset.
0484         */
0485 -      Tag(File *file, long tagOffset);
0486 +      Tag(File *file, offset_t tagOffset);
0487  
0488        /*!
0489         * Destroys this Tag instance.
0490 diff --git a/taglib/mpeg/id3v2/id3v2tag.cpp b/taglib/mpeg/id3v2/id3v2tag.cpp
0491 index f1930d0e..ba0ddb1e 100644
0492 --- a/taglib/mpeg/id3v2/id3v2tag.cpp
0493 +++ b/taglib/mpeg/id3v2/id3v2tag.cpp
0494 @@ -88,7 +88,7 @@ public:
0495    const FrameFactory *factory;
0496  
0497    File *file;
0498 -  long tagOffset;
0499 +  offset_t tagOffset;
0500  
0501    Header header;
0502    ExtendedHeader *extendedHeader;
0503 @@ -125,7 +125,7 @@ ID3v2::Tag::Tag() :
0504    d->factory = FrameFactory::instance();
0505  }
0506  
0507 -ID3v2::Tag::Tag(File *file, long tagOffset, const FrameFactory *factory) :
0508 +ID3v2::Tag::Tag(File *file, offset_t tagOffset, const FrameFactory *factory) :
0509    d(new TagPrivate())
0510  {
0511    d->factory = factory;
0512 @@ -686,9 +686,9 @@ ByteVector ID3v2::Tag::render(Version version) const
0513    else {
0514      // Padding won't increase beyond 1% of the file size or 1MB.
0515  
0516 -    long threshold = d->file ? d->file->length() / 100 : 0;
0517 -    threshold = std::max(threshold, MinPaddingSize);
0518 -    threshold = std::min(threshold, MaxPaddingSize);
0519 +    offset_t threshold = d->file ? d->file->length() / 100 : 0;
0520 +    threshold = std::max<offset_t>(threshold, MinPaddingSize);
0521 +    threshold = std::min<offset_t>(threshold, MaxPaddingSize);
0522  
0523      if(paddingSize > threshold)
0524        paddingSize = MinPaddingSize;
0525 diff --git a/taglib/mpeg/id3v2/id3v2tag.h b/taglib/mpeg/id3v2/id3v2tag.h
0526 index b0b61749..1c7bcac9 100644
0527 --- a/taglib/mpeg/id3v2/id3v2tag.h
0528 +++ b/taglib/mpeg/id3v2/id3v2tag.h
0529 @@ -146,7 +146,7 @@ namespace TagLib {
0530         *
0531         * \see FrameFactory
0532         */
0533 -      Tag(File *file, long tagOffset,
0534 +      Tag(File *file, offset_t tagOffset,
0535            const FrameFactory *factory = FrameFactory::instance());
0536  
0537        /*!
0538 diff --git a/taglib/mpeg/mpegfile.cpp b/taglib/mpeg/mpegfile.cpp
0539 index efe8af2a..a852b939 100644
0540 --- a/taglib/mpeg/mpegfile.cpp
0541 +++ b/taglib/mpeg/mpegfile.cpp
0542 @@ -63,13 +63,13 @@ public:
0543  
0544    const ID3v2::FrameFactory *ID3v2FrameFactory;
0545  
0546 -  long ID3v2Location;
0547 +  offset_t ID3v2Location;
0548    long ID3v2OriginalSize;
0549  
0550 -  long APELocation;
0551 +  offset_t APELocation;
0552    long APEOriginalSize;
0553  
0554 -  long ID3v1Location;
0555 +  offset_t ID3v1Location;
0556  
0557    TagUnion tag;
0558  
0559 @@ -105,13 +105,13 @@ bool MPEG::File::isSupported(IOStream *stream)
0560    // MPEG frame headers are really confusing with irrelevant binary data.
0561    // So we check if a frame header is really valid.
0562  
0563 -  long headerOffset;
0564 +  offset_t headerOffset;
0565    const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true, &headerOffset);
0566  
0567    if(buffer.isEmpty())
0568        return false;
0569  
0570 -  const long originalPosition = stream->tell();
0571 +  const offset_t originalPosition = stream->tell();
0572    AdapterFile file(stream);
0573  
0574    for(unsigned int i = 0; i < buffer.size() - 1; ++i) {
0575 @@ -406,7 +406,7 @@ void MPEG::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory)
0576    d->ID3v2FrameFactory = factory;
0577  }
0578  
0579 -long MPEG::File::nextFrameOffset(long position)
0580 +offset_t MPEG::File::nextFrameOffset(offset_t position)
0581  {
0582    ByteVector frameSyncBytes(2, '\0');
0583  
0584 @@ -430,12 +430,12 @@ long MPEG::File::nextFrameOffset(long position)
0585    }
0586  }
0587  
0588 -long MPEG::File::previousFrameOffset(long position)
0589 +offset_t MPEG::File::previousFrameOffset(offset_t position)
0590  {
0591    ByteVector frameSyncBytes(2, '\0');
0592  
0593    while(position > 0) {
0594 -    const long bufferLength = std::min<long>(position, bufferSize());
0595 +    const offset_t bufferLength = std::min<offset_t>(position, bufferSize());
0596      position -= bufferLength;
0597  
0598      seek(position);
0599 @@ -455,9 +455,9 @@ long MPEG::File::previousFrameOffset(long position)
0600    return -1;
0601  }
0602  
0603 -long MPEG::File::firstFrameOffset()
0604 +offset_t MPEG::File::firstFrameOffset()
0605  {
0606 -  long position = 0;
0607 +  offset_t position = 0;
0608  
0609    if(hasID3v2Tag())
0610      position = d->ID3v2Location + ID3v2Tag()->header()->completeTagSize();
0611 @@ -465,9 +465,9 @@ long MPEG::File::firstFrameOffset()
0612    return nextFrameOffset(position);
0613  }
0614  
0615 -long MPEG::File::lastFrameOffset()
0616 +offset_t MPEG::File::lastFrameOffset()
0617  {
0618 -  long position;
0619 +  offset_t position;
0620  
0621    if(hasAPETag())
0622      position = d->APELocation - 1;
0623 @@ -535,7 +535,7 @@ void MPEG::File::read(bool readProperties)
0624    ID3v1Tag(true);
0625  }
0626  
0627 -long MPEG::File::findID3v2()
0628 +offset_t MPEG::File::findID3v2()
0629  {
0630    if(!isValid())
0631      return -1;
0632 diff --git a/taglib/mpeg/mpegfile.h b/taglib/mpeg/mpegfile.h
0633 index 381d89a0..2020f154 100644
0634 --- a/taglib/mpeg/mpegfile.h
0635 +++ b/taglib/mpeg/mpegfile.h
0636 @@ -322,24 +322,24 @@ namespace TagLib {
0637        /*!
0638         * Returns the position in the file of the first MPEG frame.
0639         */
0640 -      long firstFrameOffset();
0641 +      offset_t firstFrameOffset();
0642  
0643        /*!
0644         * Returns the position in the file of the next MPEG frame,
0645         * using the current position as start
0646         */
0647 -      long nextFrameOffset(long position);
0648 +      offset_t nextFrameOffset(offset_t position);
0649  
0650        /*!
0651         * Returns the position in the file of the previous MPEG frame,
0652         * using the current position as start
0653         */
0654 -      long previousFrameOffset(long position);
0655 +      offset_t previousFrameOffset(offset_t position);
0656  
0657        /*!
0658         * Returns the position in the file of the last MPEG frame.
0659         */
0660 -      long lastFrameOffset();
0661 +      offset_t lastFrameOffset();
0662  
0663        /*!
0664         * Returns whether or not the file on disk actually has an ID3v1 tag.
0665 @@ -376,7 +376,7 @@ namespace TagLib {
0666        File &operator=(const File &);
0667  
0668        void read(bool readProperties);
0669 -      long findID3v2();
0670 +      offset_t findID3v2();
0671  
0672        class FilePrivate;
0673        FilePrivate *d;
0674 diff --git a/taglib/mpeg/mpegheader.cpp b/taglib/mpeg/mpegheader.cpp
0675 index 5a5015d6..b9405008 100644
0676 --- a/taglib/mpeg/mpegheader.cpp
0677 +++ b/taglib/mpeg/mpegheader.cpp
0678 @@ -75,7 +75,7 @@ MPEG::Header::Header(const ByteVector &data) :
0679    debug("MPEG::Header::Header() - This constructor is no longer used.");
0680  }
0681  
0682 -MPEG::Header::Header(File *file, long offset, bool checkLength) :
0683 +MPEG::Header::Header(File *file, offset_t offset, bool checkLength) :
0684    d(new HeaderPrivate())
0685  {
0686    parse(file, offset, checkLength);
0687 @@ -170,7 +170,7 @@ MPEG::Header &MPEG::Header::operator=(const Header &h)
0688  // private members
0689  ////////////////////////////////////////////////////////////////////////////////
0690  
0691 -void MPEG::Header::parse(File *file, long offset, bool checkLength)
0692 +void MPEG::Header::parse(File *file, offset_t offset, bool checkLength)
0693  {
0694    file->seek(offset);
0695    const ByteVector data = file->readBlock(4);
0696 diff --git a/taglib/mpeg/mpegheader.h b/taglib/mpeg/mpegheader.h
0697 index cb8eb251..3c260625 100644
0698 --- a/taglib/mpeg/mpegheader.h
0699 +++ b/taglib/mpeg/mpegheader.h
0700 @@ -61,7 +61,7 @@ namespace TagLib {
0701         * check if the frame length is parsed and calculated correctly.  So it's
0702         * suitable for seeking for the first valid frame.
0703         */
0704 -      Header(File *file, long offset, bool checkLength = true);
0705 +      Header(File *file, offset_t offset, bool checkLength = true);
0706  
0707        /*!
0708         * Does a shallow copy of \a h.
0709 @@ -167,7 +167,7 @@ namespace TagLib {
0710        Header &operator=(const Header &h);
0711  
0712      private:
0713 -      void parse(File *file, long offset, bool checkLength);
0714 +      void parse(File *file, offset_t offset, bool checkLength);
0715  
0716        class HeaderPrivate;
0717        HeaderPrivate *d;
0718 diff --git a/taglib/mpeg/mpegproperties.cpp b/taglib/mpeg/mpegproperties.cpp
0719 index 5eec84f7..d66f8ab1 100644
0720 --- a/taglib/mpeg/mpegproperties.cpp
0721 +++ b/taglib/mpeg/mpegproperties.cpp
0722 @@ -157,7 +157,7 @@ void MPEG::Properties::read(File *file)
0723  {
0724    // Only the first valid frame is required if we have a VBR header.
0725  
0726 -  const long firstFrameOffset = file->firstFrameOffset();
0727 +  const offset_t firstFrameOffset = file->firstFrameOffset();
0728    if(firstFrameOffset < 0) {
0729      debug("MPEG::Properties::read() -- Could not find an MPEG frame in the stream.");
0730      return;
0731 @@ -197,14 +197,14 @@ void MPEG::Properties::read(File *file)
0732  
0733      // Look for the last MPEG audio frame to calculate the stream length.
0734  
0735 -    const long lastFrameOffset = file->lastFrameOffset();
0736 +    const offset_t lastFrameOffset = file->lastFrameOffset();
0737      if(lastFrameOffset < 0) {
0738        debug("MPEG::Properties::read() -- Could not find an MPEG frame in the stream.");
0739      }
0740      else
0741      {
0742        const Header lastHeader(file, lastFrameOffset, false);
0743 -      const long streamLength = lastFrameOffset - firstFrameOffset + lastHeader.frameLength();
0744 +      const offset_t streamLength = lastFrameOffset - firstFrameOffset + lastHeader.frameLength();
0745        if (streamLength > 0)
0746          d->length = static_cast<int>(streamLength * 8.0 / d->bitrate + 0.5);
0747      }
0748 diff --git a/taglib/ogg/flac/oggflacfile.cpp b/taglib/ogg/flac/oggflacfile.cpp
0749 index 07ea9dcc..5c2f95c6 100644
0750 --- a/taglib/ogg/flac/oggflacfile.cpp
0751 +++ b/taglib/ogg/flac/oggflacfile.cpp
0752 @@ -58,8 +58,8 @@ public:
0753    Properties *properties;
0754    ByteVector streamInfoData;
0755    ByteVector xiphCommentData;
0756 -  long streamStart;
0757 -  long streamLength;
0758 +  offset_t streamStart;
0759 +  offset_t streamLength;
0760    bool scanned;
0761  
0762    bool hasXiphComment;
0763 @@ -206,7 +206,7 @@ ByteVector Ogg::FLAC::File::xiphCommentData()
0764    return d->xiphCommentData;
0765  }
0766  
0767 -long Ogg::FLAC::File::streamLength()
0768 +offset_t Ogg::FLAC::File::streamLength()
0769  {
0770    scan();
0771    return d->streamLength;
0772 @@ -223,7 +223,7 @@ void Ogg::FLAC::File::scan()
0773      return;
0774  
0775    int ipacket = 0;
0776 -  long overhead = 0;
0777 +  offset_t overhead = 0;
0778  
0779    ByteVector metadataHeader = packet(ipacket);
0780    if(metadataHeader.isEmpty())
0781 diff --git a/taglib/ogg/flac/oggflacfile.h b/taglib/ogg/flac/oggflacfile.h
0782 index b2686e45..0e5e1ac4 100644
0783 --- a/taglib/ogg/flac/oggflacfile.h
0784 +++ b/taglib/ogg/flac/oggflacfile.h
0785 @@ -134,7 +134,7 @@ namespace TagLib {
0786         * Returns the length of the audio-stream, used by FLAC::Properties for
0787         * calculating the bitrate.
0788         */
0789 -      long streamLength();
0790 +      offset_t streamLength();
0791  
0792        /*!
0793         * Returns whether or not the file on disk actually has a XiphComment.
0794 diff --git a/taglib/ogg/oggfile.cpp b/taglib/ogg/oggfile.cpp
0795 index 1f2cce93..86063915 100644
0796 --- a/taglib/ogg/oggfile.cpp
0797 +++ b/taglib/ogg/oggfile.cpp
0798 @@ -129,7 +129,7 @@ void Ogg::File::setPacket(unsigned int i, const ByteVector &p)
0799  const Ogg::PageHeader *Ogg::File::firstPageHeader()
0800  {
0801    if(!d->firstPageHeader) {
0802 -    const long firstPageHeaderOffset = find("OggS");
0803 +    const offset_t firstPageHeaderOffset = find("OggS");
0804      if(firstPageHeaderOffset < 0)
0805        return 0;
0806  
0807 @@ -142,7 +142,7 @@ const Ogg::PageHeader *Ogg::File::firstPageHeader()
0808  const Ogg::PageHeader *Ogg::File::lastPageHeader()
0809  {
0810    if(!d->lastPageHeader) {
0811 -    const long lastPageHeaderOffset = rfind("OggS");
0812 +    const offset_t lastPageHeaderOffset = rfind("OggS");
0813      if(lastPageHeaderOffset < 0)
0814        return 0;
0815  
0816 @@ -192,7 +192,7 @@ bool Ogg::File::readPages(unsigned int i)
0817  {
0818    while(true) {
0819      unsigned int packetIndex;
0820 -    long offset;
0821 +    offset_t offset;
0822  
0823      if(d->pages.isEmpty()) {
0824        packetIndex = 0;
0825 @@ -275,8 +275,8 @@ void Ogg::File::writePacket(unsigned int i, const ByteVector &packet)
0826    for(it = pages.begin(); it != pages.end(); ++it)
0827      data.append((*it)->render());
0828  
0829 -  const unsigned long originalOffset = firstPage->fileOffset();
0830 -  const unsigned long originalLength = lastPage->fileOffset() + lastPage->size() - originalOffset;
0831 +  const offset_t originalOffset = firstPage->fileOffset();
0832 +  const offset_t originalLength = lastPage->fileOffset() + lastPage->size() - originalOffset;
0833  
0834    insert(data, originalOffset, originalLength);
0835  
0836 @@ -286,7 +286,7 @@ void Ogg::File::writePacket(unsigned int i, const ByteVector &packet)
0837      = pages.back()->pageSequenceNumber() - lastPage->pageSequenceNumber();
0838  
0839    if(numberOfNewPages != 0) {
0840 -    long pageOffset = originalOffset + data.size();
0841 +    offset_t pageOffset = originalOffset + data.size();
0842  
0843      while(true) {
0844        Page page(this, pageOffset);
0845 diff --git a/taglib/ogg/oggpage.cpp b/taglib/ogg/oggpage.cpp
0846 index 869c357a..990b4c4f 100644
0847 --- a/taglib/ogg/oggpage.cpp
0848 +++ b/taglib/ogg/oggpage.cpp
0849 @@ -37,14 +37,14 @@ using namespace TagLib;
0850  class Ogg::Page::PagePrivate
0851  {
0852  public:
0853 -  PagePrivate(File *f = 0, long pageOffset = -1) :
0854 +  PagePrivate(File *f = 0, offset_t pageOffset = -1) :
0855      file(f),
0856      fileOffset(pageOffset),
0857      header(f, pageOffset),
0858      firstPacketIndex(-1) {}
0859  
0860    File *file;
0861 -  long fileOffset;
0862 +  offset_t fileOffset;
0863    PageHeader header;
0864    int firstPacketIndex;
0865    ByteVectorList packets;
0866 @@ -54,7 +54,7 @@ public:
0867  // public members
0868  ////////////////////////////////////////////////////////////////////////////////
0869  
0870 -Ogg::Page::Page(Ogg::File *file, long pageOffset) :
0871 +Ogg::Page::Page(Ogg::File *file, offset_t pageOffset) :
0872    d(new PagePrivate(file, pageOffset))
0873  {
0874  }
0875 @@ -64,7 +64,7 @@ Ogg::Page::~Page()
0876    delete d;
0877  }
0878  
0879 -long Ogg::Page::fileOffset() const
0880 +offset_t Ogg::Page::fileOffset() const
0881  {
0882    return d->fileOffset;
0883  }
0884 diff --git a/taglib/ogg/oggpage.h b/taglib/ogg/oggpage.h
0885 index 4829b070..4ed704f6 100644
0886 --- a/taglib/ogg/oggpage.h
0887 +++ b/taglib/ogg/oggpage.h
0888 @@ -55,14 +55,14 @@ namespace TagLib {
0889        /*!
0890         * Read an Ogg page from the \a file at the position \a pageOffset.
0891         */
0892 -      Page(File *file, long pageOffset);
0893 +      Page(File *file, offset_t pageOffset);
0894  
0895        virtual ~Page();
0896  
0897        /*!
0898         * Returns the page's position within the file (in bytes).
0899         */
0900 -      long fileOffset() const;
0901 +      offset_t fileOffset() const;
0902  
0903        /*!
0904         * Returns a pointer to the header for this page.  This pointer will become
0905 diff --git a/taglib/ogg/oggpageheader.cpp b/taglib/ogg/oggpageheader.cpp
0906 index 3c3c4ee1..10a1efc2 100644
0907 --- a/taglib/ogg/oggpageheader.cpp
0908 +++ b/taglib/ogg/oggpageheader.cpp
0909 @@ -66,7 +66,7 @@ public:
0910  // public members
0911  ////////////////////////////////////////////////////////////////////////////////
0912  
0913 -Ogg::PageHeader::PageHeader(Ogg::File *file, long pageOffset) :
0914 +Ogg::PageHeader::PageHeader(Ogg::File *file, offset_t pageOffset) :
0915    d(new PageHeaderPrivate())
0916  {
0917    if(file && pageOffset >= 0)
0918 @@ -225,7 +225,7 @@ ByteVector Ogg::PageHeader::render() const
0919  // private members
0920  ////////////////////////////////////////////////////////////////////////////////
0921  
0922 -void Ogg::PageHeader::read(Ogg::File *file, long pageOffset)
0923 +void Ogg::PageHeader::read(Ogg::File *file, offset_t pageOffset)
0924  {
0925    file->seek(pageOffset);
0926  
0927 diff --git a/taglib/ogg/oggpageheader.h b/taglib/ogg/oggpageheader.h
0928 index d62feb3d..29709626 100644
0929 --- a/taglib/ogg/oggpageheader.h
0930 +++ b/taglib/ogg/oggpageheader.h
0931 @@ -52,7 +52,7 @@ namespace TagLib {
0932         * create a page with no (and as such, invalid) data that must be set
0933         * later.
0934         */
0935 -      PageHeader(File *file = 0, long pageOffset = -1);
0936 +      PageHeader(File *file = 0, offset_t pageOffset = -1);
0937  
0938        /*!
0939         * Deletes this instance of the PageHeader.
0940 @@ -219,7 +219,7 @@ namespace TagLib {
0941        PageHeader(const PageHeader &);
0942        PageHeader &operator=(const PageHeader &);
0943  
0944 -      void read(Ogg::File *file, long pageOffset);
0945 +      void read(Ogg::File *file, offset_t pageOffset);
0946        ByteVector lacingValues() const;
0947  
0948        class PageHeaderPrivate;
0949 diff --git a/taglib/ogg/opus/opusproperties.cpp b/taglib/ogg/opus/opusproperties.cpp
0950 index b60cc01d..e19ab64d 100644
0951 --- a/taglib/ogg/opus/opusproperties.cpp
0952 +++ b/taglib/ogg/opus/opusproperties.cpp
0953 @@ -163,7 +163,7 @@ void Opus::Properties::read(File *file)
0954  
0955        if(frameCount > 0) {
0956          const double length = frameCount * 1000.0 / 48000.0;
0957 -        long fileLengthWithoutOverhead = file->length();
0958 +        offset_t fileLengthWithoutOverhead = file->length();
0959          // Ignore the two mandatory header packets, see "3. Packet Organization"
0960          // in https://tools.ietf.org/html/rfc7845.html
0961          for (unsigned int i = 0; i < 2; ++i) {
0962 diff --git a/taglib/ogg/speex/speexproperties.cpp b/taglib/ogg/speex/speexproperties.cpp
0963 index b7a11cc6..fae184a0 100644
0964 --- a/taglib/ogg/speex/speexproperties.cpp
0965 +++ b/taglib/ogg/speex/speexproperties.cpp
0966 @@ -182,7 +182,7 @@ void Speex::Properties::read(File *file)
0967  
0968        if(frameCount > 0) {
0969          const double length = frameCount * 1000.0 / d->sampleRate;
0970 -        long fileLengthWithoutOverhead = file->length();
0971 +        offset_t fileLengthWithoutOverhead = file->length();
0972          // Ignore the two header packets, see "Ogg file format" in
0973          // https://www.speex.org/docs/manual/speex-manual/node8.html
0974          for (unsigned int i = 0; i < 2; ++i) {
0975 diff --git a/taglib/ogg/vorbis/vorbisproperties.cpp b/taglib/ogg/vorbis/vorbisproperties.cpp
0976 index c2909204..b38e138a 100644
0977 --- a/taglib/ogg/vorbis/vorbisproperties.cpp
0978 +++ b/taglib/ogg/vorbis/vorbisproperties.cpp
0979 @@ -186,7 +186,7 @@ void Vorbis::Properties::read(File *file)
0980  
0981        if(frameCount > 0) {
0982          const double length = frameCount * 1000.0 / d->sampleRate;
0983 -        long fileLengthWithoutOverhead = file->length();
0984 +        offset_t fileLengthWithoutOverhead = file->length();
0985          // Ignore the three initial header packets, see "1.3.1. Decode Setup" in
0986          // https://xiph.org/vorbis/doc/Vorbis_I_spec.html
0987          for (unsigned int i = 0; i < 3; ++i) {
0988 diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp
0989 index 005551f4..87ce7240 100644
0990 --- a/taglib/riff/rifffile.cpp
0991 +++ b/taglib/riff/rifffile.cpp
0992 @@ -38,7 +38,7 @@ using namespace TagLib;
0993  struct Chunk
0994  {
0995    ByteVector   name;
0996 -  unsigned int offset;
0997 +  offset_t offset;
0998    unsigned int size;
0999    unsigned int padding;
1000  };
1001 @@ -54,7 +54,7 @@ public:
1002    const Endianness endianness;
1003  
1004    unsigned int size;
1005 -  long sizeOffset;
1006 +  offset_t sizeOffset;
1007  
1008    std::vector<Chunk> chunks;
1009  };
1010 @@ -108,7 +108,7 @@ unsigned int RIFF::File::chunkDataSize(unsigned int i) const
1011    return d->chunks[i].size;
1012  }
1013  
1014 -unsigned int RIFF::File::chunkOffset(unsigned int i) const
1015 +offset_t RIFF::File::chunkOffset(unsigned int i) const
1016  {
1017    if(i >= d->chunks.size()) {
1018      debug("RIFF::File::chunkOffset() - Index out of range. Returning 0.");
1019 @@ -212,7 +212,7 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo
1020  
1021    Chunk &last = d->chunks.back();
1022  
1023 -  long offset = last.offset + last.size + last.padding;
1024 +  offset_t offset = last.offset + last.size + last.padding;
1025    if(offset & 1) {
1026      if(last.padding == 1) {
1027        last.padding = 0; // This should not happen unless the file is corrupted.
1028 @@ -283,7 +283,7 @@ void RIFF::File::read()
1029  {
1030    const bool bigEndian = (d->endianness == BigEndian);
1031  
1032 -  long offset = tell();
1033 +  offset_t offset = tell();
1034  
1035    offset += 4;
1036    d->sizeOffset = offset;
1037 @@ -345,7 +345,7 @@ void RIFF::File::read()
1038  }
1039  
1040  void RIFF::File::writeChunk(const ByteVector &name, const ByteVector &data,
1041 -                            unsigned long offset, unsigned long replace)
1042 +                            offset_t offset, unsigned long replace)
1043  {
1044    ByteVector combined;
1045  
1046 diff --git a/taglib/riff/rifffile.h b/taglib/riff/rifffile.h
1047 index 1ed49503..314dc4d9 100644
1048 --- a/taglib/riff/rifffile.h
1049 +++ b/taglib/riff/rifffile.h
1050 @@ -71,7 +71,7 @@ namespace TagLib {
1051        /*!
1052         * \return The offset within the file for the selected chunk number.
1053         */
1054 -      unsigned int chunkOffset(unsigned int i) const;
1055 +      offset_t chunkOffset(unsigned int i) const;
1056  
1057        /*!
1058         * \return The size of the chunk data.
1059 @@ -145,7 +145,7 @@ namespace TagLib {
1060  
1061        void read();
1062        void writeChunk(const ByteVector &name, const ByteVector &data,
1063 -                      unsigned long offset, unsigned long replace = 0);
1064 +                      offset_t offset, unsigned long replace = 0);
1065  
1066        /*!
1067         * Update the global RIFF size based on the current internal structure.
1068 diff --git a/taglib/tagutils.cpp b/taglib/tagutils.cpp
1069 index 5fcd12aa..27154dc3 100644
1070 --- a/taglib/tagutils.cpp
1071 +++ b/taglib/tagutils.cpp
1072 @@ -33,7 +33,7 @@
1073  
1074  using namespace TagLib;
1075  
1076 -long Utils::findID3v1(File *file)
1077 +offset_t Utils::findID3v1(File *file)
1078  {
1079    if(!file->isValid())
1080      return -1;
1081 @@ -42,14 +42,14 @@ long Utils::findID3v1(File *file)
1082  
1083    if (file->length() >= 131) {
1084      file->seek(-131, File::End);
1085 -    const long p = file->tell() + 3;
1086 +    const offset_t p = file->tell() + 3;
1087      const TagLib::ByteVector data = file->readBlock(8);
1088  
1089      if(data.containsAt(ID3v1::Tag::fileIdentifier(), 3) && (data != APE::Tag::fileIdentifier()))
1090        return p;
1091    } else {
1092      file->seek(-128, File::End);
1093 -    const long p = file->tell();
1094 +    const offset_t p = file->tell();
1095  
1096      if(file->readBlock(3) == ID3v1::Tag::fileIdentifier())
1097        return p;
1098 @@ -58,7 +58,7 @@ long Utils::findID3v1(File *file)
1099    return -1;
1100  }
1101  
1102 -long Utils::findID3v2(File *file)
1103 +offset_t Utils::findID3v2(File *file)
1104  {
1105    if(!file->isValid())
1106      return -1;
1107 @@ -71,7 +71,7 @@ long Utils::findID3v2(File *file)
1108    return -1;
1109  }
1110  
1111 -long Utils::findAPE(File *file, long id3v1Location)
1112 +offset_t Utils::findAPE(File *file, offset_t id3v1Location)
1113  {
1114    if(!file->isValid())
1115      return -1;
1116 @@ -81,7 +81,7 @@ long Utils::findAPE(File *file, long id3v1Location)
1117    else
1118      file->seek(-32, File::End);
1119  
1120 -  const long p = file->tell();
1121 +  const offset_t p = file->tell();
1122  
1123    if(file->readBlock(8) == APE::Tag::fileIdentifier())
1124      return p;
1125 @@ -90,13 +90,13 @@ long Utils::findAPE(File *file, long id3v1Location)
1126  }
1127  
1128  ByteVector TagLib::Utils::readHeader(IOStream *stream, unsigned int length,
1129 -                                     bool skipID3v2, long *headerOffset)
1130 +                                     bool skipID3v2, offset_t *headerOffset)
1131  {
1132    if(!stream || !stream->isOpen())
1133      return ByteVector();
1134  
1135 -  const long originalPosition = stream->tell();
1136 -  long bufferOffset = 0;
1137 +  const offset_t originalPosition = stream->tell();
1138 +  offset_t bufferOffset = 0;
1139  
1140    if(skipID3v2) {
1141      stream->seek(0);
1142 diff --git a/taglib/tagutils.h b/taglib/tagutils.h
1143 index b7863494..c2bba562 100644
1144 --- a/taglib/tagutils.h
1145 +++ b/taglib/tagutils.h
1146 @@ -39,14 +39,14 @@ namespace TagLib {
1147  
1148    namespace Utils {
1149  
1150 -    long findID3v1(File *file);
1151 +    offset_t findID3v1(File *file);
1152  
1153 -    long findID3v2(File *file);
1154 +    offset_t findID3v2(File *file);
1155  
1156 -    long findAPE(File *file, long id3v1Location);
1157 +    offset_t findAPE(File *file, offset_t id3v1Location);
1158  
1159      ByteVector readHeader(IOStream *stream, unsigned int length, bool skipID3v2,
1160 -                          long *headerOffset = 0);
1161 +                          offset_t *headerOffset = 0);
1162    }  // namespace Utils
1163  }  // namespace TagLib
1164  
1165 diff --git a/taglib/toolkit/taglib.h b/taglib/toolkit/taglib.h
1166 index 64ccf0a8..21e6d5ff 100644
1167 --- a/taglib/toolkit/taglib.h
1168 +++ b/taglib/toolkit/taglib.h
1169 @@ -54,6 +54,11 @@
1170  #define TAGLIB_DEPRECATED
1171  #endif
1172  
1173 +#define TAGLIB_WITH_OFFSET_TYPE
1174 +#ifndef _WIN32
1175 +#include <sys/types.h>
1176 +#endif
1177 +
1178  #include <string>
1179  
1180  //! A namespace for all TagLib related classes and functions
1181 @@ -79,6 +84,14 @@ namespace TagLib {
1182    typedef unsigned long      ulong;
1183    typedef unsigned long long ulonglong;
1184  
1185 +  // Offset or length type for I/O streams.
1186 +  // In Win32, always 64bit. Otherwise, equivalent to off_t.
1187 +#ifdef _WIN32
1188 +  typedef long long offset_t;
1189 +#else
1190 +  typedef off_t     offset_t;
1191 +#endif
1192 +
1193    /*!
1194     * Unfortunately std::wstring isn't defined on some systems, (i.e. GCC < 3)
1195     * so I'm providing something here that should be constant.
1196 diff --git a/taglib/toolkit/tbytevectorstream.cpp b/taglib/toolkit/tbytevectorstream.cpp
1197 index bce3a7c6..09053597 100644
1198 --- a/taglib/toolkit/tbytevectorstream.cpp
1199 +++ b/taglib/toolkit/tbytevectorstream.cpp
1200 @@ -40,7 +40,7 @@ public:
1201    ByteVectorStreamPrivate(const ByteVector &data);
1202  
1203    ByteVector data;
1204 -  long position;
1205 +  offset_t position;
1206  };
1207  
1208  ByteVectorStream::ByteVectorStreamPrivate::ByteVectorStreamPrivate(const ByteVector &data) :
1209 @@ -88,7 +88,7 @@ void ByteVectorStream::writeBlock(const ByteVector &data)
1210    d->position += size;
1211  }
1212  
1213 -void ByteVectorStream::insert(const ByteVector &data, unsigned long start, unsigned long replace)
1214 +void ByteVectorStream::insert(const ByteVector &data, offset_t start, unsigned long replace)
1215  {
1216    long sizeDiff = data.size() - replace;
1217    if(sizeDiff < 0) {
1218 @@ -96,20 +96,20 @@ void ByteVectorStream::insert(const ByteVector &data, unsigned long start, unsig
1219    }
1220    else if(sizeDiff > 0) {
1221      truncate(length() + sizeDiff);
1222 -    unsigned long readPosition  = start + replace;
1223 -    unsigned long writePosition = start + data.size();
1224 +    offset_t readPosition  = start + replace;
1225 +    offset_t writePosition = start + data.size();
1226      memmove(d->data.data() + writePosition, d->data.data() + readPosition, length() - sizeDiff - readPosition);
1227    }
1228    seek(start);
1229    writeBlock(data);
1230  }
1231  
1232 -void ByteVectorStream::removeBlock(unsigned long start, unsigned long length)
1233 +void ByteVectorStream::removeBlock(offset_t start, unsigned long length)
1234  {
1235 -  unsigned long readPosition = start + length;
1236 -  unsigned long writePosition = start;
1237 -  if(readPosition < static_cast<unsigned long>(ByteVectorStream::length())) {
1238 -    unsigned long bytesToMove = ByteVectorStream::length() - readPosition;
1239 +  offset_t readPosition = start + length;
1240 +  offset_t writePosition = start;
1241 +  if(readPosition < ByteVectorStream::length()) {
1242 +    offset_t bytesToMove = ByteVectorStream::length() - readPosition;
1243      memmove(d->data.data() + writePosition, d->data.data() + readPosition, bytesToMove);
1244      writePosition += bytesToMove;
1245    }
1246 @@ -127,7 +127,7 @@ bool ByteVectorStream::isOpen() const
1247    return true;
1248  }
1249  
1250 -void ByteVectorStream::seek(long offset, Position p)
1251 +void ByteVectorStream::seek(offset_t offset, Position p)
1252  {
1253    switch(p) {
1254    case Beginning:
1255 @@ -146,17 +146,17 @@ void ByteVectorStream::clear()
1256  {
1257  }
1258  
1259 -long ByteVectorStream::tell() const
1260 +offset_t ByteVectorStream::tell() const
1261  {
1262    return d->position;
1263  }
1264  
1265 -long ByteVectorStream::length()
1266 +offset_t ByteVectorStream::length()
1267  {
1268    return d->data.size();
1269  }
1270  
1271 -void ByteVectorStream::truncate(long length)
1272 +void ByteVectorStream::truncate(offset_t length)
1273  {
1274    d->data.resize(length);
1275  }
1276 diff --git a/taglib/toolkit/tbytevectorstream.h b/taglib/toolkit/tbytevectorstream.h
1277 index 5aa8fcfd..8c2f4fa4 100644
1278 --- a/taglib/toolkit/tbytevectorstream.h
1279 +++ b/taglib/toolkit/tbytevectorstream.h
1280 @@ -81,7 +81,7 @@ namespace TagLib {
1281       * \note This method is slow since it requires rewriting all of the file
1282       * after the insertion point.
1283       */
1284 -    void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
1285 +    void insert(const ByteVector &data, offset_t start = 0, unsigned long replace = 0);
1286  
1287      /*!
1288       * Removes a block of the file starting a \a start and continuing for
1289 @@ -90,7 +90,7 @@ namespace TagLib {
1290       * \note This method is slow since it involves rewriting all of the file
1291       * after the removed portion.
1292       */
1293 -    void removeBlock(unsigned long start = 0, unsigned long length = 0);
1294 +    void removeBlock(offset_t start = 0, unsigned long length = 0);
1295  
1296      /*!
1297       * Returns true if the file is read only (or if the file can not be opened).
1298 @@ -109,7 +109,7 @@ namespace TagLib {
1299       *
1300       * \see Position
1301       */
1302 -    void seek(long offset, Position p = Beginning);
1303 +    void seek(offset_t offset, Position p = Beginning);
1304  
1305      /*!
1306       * Reset the end-of-file and error flags on the file.
1307 @@ -119,17 +119,17 @@ namespace TagLib {
1308      /*!
1309       * Returns the current offset within the file.
1310       */
1311 -    long tell() const;
1312 +    offset_t tell() const;
1313  
1314      /*!
1315       * Returns the length of the file.
1316       */
1317 -    long length();
1318 +    offset_t length();
1319  
1320      /*!
1321       * Truncates the file to a \a length.
1322       */
1323 -    void truncate(long length);
1324 +    void truncate(offset_t length);
1325  
1326      ByteVector *data();
1327  
1328 diff --git a/taglib/toolkit/tfile.cpp b/taglib/toolkit/tfile.cpp
1329 index 4f7bf6e7..9fe31e16 100644
1330 --- a/taglib/toolkit/tfile.cpp
1331 +++ b/taglib/toolkit/tfile.cpp
1332 @@ -231,14 +231,14 @@ void File::writeBlock(const ByteVector &data)
1333    d->stream->writeBlock(data);
1334  }
1335  
1336 -long File::find(const ByteVector &pattern, long fromOffset, const ByteVector &before)
1337 +offset_t File::find(const ByteVector &pattern, offset_t fromOffset, const ByteVector &before)
1338  {
1339    if(!d->stream || pattern.size() > bufferSize())
1340        return -1;
1341  
1342    // The position in the file that the current buffer starts at.
1343  
1344 -  long bufferOffset = fromOffset;
1345 +  offset_t bufferOffset = fromOffset;
1346    ByteVector buffer;
1347  
1348    // These variables are used to keep track of a partial match that happens at
1349 @@ -250,7 +250,7 @@ long File::find(const ByteVector &pattern, long fromOffset, const ByteVector &be
1350    // Save the location of the current read pointer.  We will restore the
1351    // position using seek() before all returns.
1352  
1353 -  long originalPosition = tell();
1354 +  offset_t originalPosition = tell();
1355  
1356    // Start the search at the offset.
1357  
1358 @@ -327,7 +327,7 @@ long File::find(const ByteVector &pattern, long fromOffset, const ByteVector &be
1359  }
1360  
1361  
1362 -long File::rfind(const ByteVector &pattern, long fromOffset, const ByteVector &before)
1363 +offset_t File::rfind(const ByteVector &pattern, offset_t fromOffset, const ByteVector &before)
1364  {
1365    if(!d->stream || pattern.size() > bufferSize())
1366        return -1;
1367 @@ -347,15 +347,15 @@ long File::rfind(const ByteVector &pattern, long fromOffset, const ByteVector &b
1368    // Save the location of the current read pointer.  We will restore the
1369    // position using seek() before all returns.
1370  
1371 -  long originalPosition = tell();
1372 +  offset_t originalPosition = tell();
1373  
1374    // Start the search at the offset.
1375  
1376    if(fromOffset == 0)
1377      fromOffset = length();
1378  
1379 -  long bufferLength = bufferSize();
1380 -  long bufferOffset = fromOffset + pattern.size();
1381 +  offset_t bufferLength = bufferSize();
1382 +  offset_t bufferOffset = fromOffset + pattern.size();
1383  
1384    // See the notes in find() for an explanation of this algorithm.
1385  
1386 @@ -401,12 +401,12 @@ long File::rfind(const ByteVector &pattern, long fromOffset, const ByteVector &b
1387    return -1;
1388  }
1389  
1390 -void File::insert(const ByteVector &data, unsigned long start, unsigned long replace)
1391 +void File::insert(const ByteVector &data, offset_t start, unsigned long replace)
1392  {
1393    d->stream->insert(data, start, replace);
1394  }
1395  
1396 -void File::removeBlock(unsigned long start, unsigned long length)
1397 +void File::removeBlock(offset_t start, unsigned long length)
1398  {
1399    d->stream->removeBlock(start, length);
1400  }
1401 @@ -426,12 +426,12 @@ bool File::isValid() const
1402    return isOpen() && d->valid;
1403  }
1404  
1405 -void File::seek(long offset, Position p)
1406 +void File::seek(offset_t offset, Position p)
1407  {
1408    d->stream->seek(offset, static_cast<IOStream::Position>(p));
1409  }
1410  
1411 -void File::truncate(long length)
1412 +void File::truncate(offset_t length)
1413  {
1414    d->stream->truncate(length);
1415  }
1416 @@ -441,12 +441,12 @@ void File::clear()
1417    d->stream->clear();
1418  }
1419  
1420 -long File::tell() const
1421 +offset_t File::tell() const
1422  {
1423    return d->stream->tell();
1424  }
1425  
1426 -long File::length()
1427 +offset_t File::length()
1428  {
1429    return d->stream->length();
1430  }
1431 diff --git a/taglib/toolkit/tfile.h b/taglib/toolkit/tfile.h
1432 index bb8c2b30..c024c4e8 100644
1433 --- a/taglib/toolkit/tfile.h
1434 +++ b/taglib/toolkit/tfile.h
1435 @@ -180,8 +180,8 @@ namespace TagLib {
1436       * \note This has the practical limitation that \a pattern can not be longer
1437       * than the buffer size used by readBlock().  Currently this is 1024 bytes.
1438       */
1439 -    long find(const ByteVector &pattern,
1440 -              long fromOffset = 0,
1441 +    offset_t find(const ByteVector &pattern,
1442 +              offset_t fromOffset = 0,
1443                const ByteVector &before = ByteVector());
1444  
1445      /*!
1446 @@ -196,8 +196,8 @@ namespace TagLib {
1447       * \note This has the practical limitation that \a pattern can not be longer
1448       * than the buffer size used by readBlock().  Currently this is 1024 bytes.
1449       */
1450 -    long rfind(const ByteVector &pattern,
1451 -               long fromOffset = 0,
1452 +    offset_t rfind(const ByteVector &pattern,
1453 +               offset_t fromOffset = 0,
1454                 const ByteVector &before = ByteVector());
1455  
1456      /*!
1457 @@ -207,7 +207,7 @@ namespace TagLib {
1458       * \note This method is slow since it requires rewriting all of the file
1459       * after the insertion point.
1460       */
1461 -    void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
1462 +    void insert(const ByteVector &data, offset_t start = 0, unsigned long replace = 0);
1463  
1464      /*!
1465       * Removes a block of the file starting a \a start and continuing for
1466 @@ -216,7 +216,7 @@ namespace TagLib {
1467       * \note This method is slow since it involves rewriting all of the file
1468       * after the removed portion.
1469       */
1470 -    void removeBlock(unsigned long start = 0, unsigned long length = 0);
1471 +    void removeBlock(offset_t start = 0, unsigned long length = 0);
1472  
1473      /*!
1474       * Returns true if the file is read only (or if the file can not be opened).
1475 @@ -240,7 +240,7 @@ namespace TagLib {
1476       *
1477       * \see Position
1478       */
1479 -    void seek(long offset, Position p = Beginning);
1480 +    void seek(offset_t offset, Position p = Beginning);
1481  
1482      /*!
1483       * Reset the end-of-file and error flags on the file.
1484 @@ -250,12 +250,12 @@ namespace TagLib {
1485      /*!
1486       * Returns the current offset within the file.
1487       */
1488 -    long tell() const;
1489 +    offset_t tell() const;
1490  
1491      /*!
1492       * Returns the length of the file.
1493       */
1494 -    long length();
1495 +    offset_t length();
1496  
1497      /*!
1498       * Returns true if \a file can be opened for reading.  If the file does not
1499 @@ -303,7 +303,7 @@ namespace TagLib {
1500      /*!
1501       * Truncates the file to a \a length.
1502       */
1503 -    void truncate(long length);
1504 +    void truncate(offset_t length);
1505  
1506      /*!
1507       * Returns the buffer size that is used for internal buffering.
1508 diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp
1509 index 989e1d23..85a859f9 100644
1510 --- a/taglib/toolkit/tfilestream.cpp
1511 +++ b/taglib/toolkit/tfilestream.cpp
1512 @@ -236,7 +236,7 @@ void FileStream::writeBlock(const ByteVector &data)
1513    writeFile(d->file, data);
1514  }
1515  
1516 -void FileStream::insert(const ByteVector &data, unsigned long start, unsigned long replace)
1517 +void FileStream::insert(const ByteVector &data, offset_t start, unsigned long replace)
1518  {
1519    if(!isOpen()) {
1520      debug("FileStream::insert() -- invalid file.");
1521 @@ -270,15 +270,15 @@ void FileStream::insert(const ByteVector &data, unsigned long start, unsigned lo
1522    // the *difference* in the tag sizes.  We want to avoid overwriting parts
1523    // that aren't yet in memory, so this is necessary.
1524  
1525 -  unsigned long bufferLength = bufferSize();
1526 +  size_t bufferLength = bufferSize();
1527  
1528    while(data.size() - replace > bufferLength)
1529      bufferLength += bufferSize();
1530  
1531    // Set where to start the reading and writing.
1532  
1533 -  long readPosition = start + replace;
1534 -  long writePosition = start;
1535 +  offset_t readPosition = start + replace;
1536 +  offset_t writePosition = start;
1537  
1538    ByteVector buffer = data;
1539    ByteVector aboutToOverwrite(static_cast<unsigned int>(bufferLength));
1540 @@ -317,7 +317,7 @@ void FileStream::insert(const ByteVector &data, unsigned long start, unsigned lo
1541    }
1542  }
1543  
1544 -void FileStream::removeBlock(unsigned long start, unsigned long length)
1545 +void FileStream::removeBlock(offset_t start, unsigned long length)
1546  {
1547    if(!isOpen()) {
1548      debug("FileStream::removeBlock() -- invalid file.");
1549 @@ -326,8 +326,8 @@ void FileStream::removeBlock(unsigned long start, unsigned long length)
1550  
1551    unsigned long bufferLength = bufferSize();
1552  
1553 -  long readPosition = start + length;
1554 -  long writePosition = start;
1555 +  offset_t readPosition = start + length;
1556 +  offset_t writePosition = start;
1557  
1558    ByteVector buffer(static_cast<unsigned int>(bufferLength));
1559  
1560 @@ -363,7 +363,7 @@ bool FileStream::isOpen() const
1561    return (d->file != InvalidFileHandle);
1562  }
1563  
1564 -void FileStream::seek(long offset, Position p)
1565 +void FileStream::seek(offset_t offset, Position p)
1566  {
1567    if(!isOpen()) {
1568      debug("FileStream::seek() -- invalid file.");
1569 @@ -420,16 +420,15 @@ void FileStream::clear()
1570  #endif
1571  }
1572  
1573 -long FileStream::tell() const
1574 +offset_t FileStream::tell() const
1575  {
1576  #ifdef _WIN32
1577  
1578    const LARGE_INTEGER zero = {};
1579    LARGE_INTEGER position;
1580  
1581 -  if(SetFilePointerEx(d->file, zero, &position, FILE_CURRENT) &&
1582 -     position.QuadPart <= LONG_MAX) {
1583 -    return static_cast<long>(position.QuadPart);
1584 +  if(SetFilePointerEx(d->file, zero, &position, FILE_CURRENT)) {
1585 +    return position.QuadPart;
1586    }
1587    else {
1588      debug("FileStream::tell() -- Failed to get the file pointer.");
1589 @@ -443,7 +442,7 @@ long FileStream::tell() const
1590  #endif
1591  }
1592  
1593 -long FileStream::length()
1594 +offset_t FileStream::length()
1595  {
1596    if(!isOpen()) {
1597      debug("FileStream::length() -- invalid file.");
1598 @@ -454,8 +453,8 @@ long FileStream::length()
1599  
1600    LARGE_INTEGER fileSize;
1601  
1602 -  if(GetFileSizeEx(d->file, &fileSize) && fileSize.QuadPart <= LONG_MAX) {
1603 -    return static_cast<long>(fileSize.QuadPart);
1604 +  if(GetFileSizeEx(d->file, &fileSize)) {
1605 +    return fileSize.QuadPart;
1606    }
1607    else {
1608      debug("FileStream::length() -- Failed to get the file size.");
1609 @@ -464,10 +463,10 @@ long FileStream::length()
1610  
1611  #else
1612  
1613 -  const long curpos = tell();
1614 +  const offset_t curpos = tell();
1615  
1616    seek(0, End);
1617 -  const long endpos = tell();
1618 +  const offset_t endpos = tell();
1619  
1620    seek(curpos, Beginning);
1621  
1622 @@ -480,11 +479,11 @@ long FileStream::length()
1623  // protected members
1624  ////////////////////////////////////////////////////////////////////////////////
1625  
1626 -void FileStream::truncate(long length)
1627 +void FileStream::truncate(offset_t length)
1628  {
1629  #ifdef _WIN32
1630  
1631 -  const long currentPos = tell();
1632 +  const offset_t currentPos = tell();
1633  
1634    seek(length);
1635  
1636 diff --git a/taglib/toolkit/tfilestream.h b/taglib/toolkit/tfilestream.h
1637 index dd3b8652..6fee9f05 100644
1638 --- a/taglib/toolkit/tfilestream.h
1639 +++ b/taglib/toolkit/tfilestream.h
1640 @@ -92,7 +92,7 @@ namespace TagLib {
1641       * \note This method is slow since it requires rewriting all of the file
1642       * after the insertion point.
1643       */
1644 -    void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
1645 +    void insert(const ByteVector &data, offset_t start = 0, unsigned long replace = 0);
1646  
1647      /*!
1648       * Removes a block of the file starting a \a start and continuing for
1649 @@ -101,7 +101,7 @@ namespace TagLib {
1650       * \note This method is slow since it involves rewriting all of the file
1651       * after the removed portion.
1652       */
1653 -    void removeBlock(unsigned long start = 0, unsigned long length = 0);
1654 +    void removeBlock(offset_t start = 0, unsigned long length = 0);
1655  
1656      /*!
1657       * Returns true if the file is read only (or if the file can not be opened).
1658 @@ -120,7 +120,7 @@ namespace TagLib {
1659       *
1660       * \see Position
1661       */
1662 -    void seek(long offset, Position p = Beginning);
1663 +    void seek(offset_t offset, Position p = Beginning);
1664  
1665      /*!
1666       * Reset the end-of-file and error flags on the file.
1667 @@ -130,17 +130,17 @@ namespace TagLib {
1668      /*!
1669       * Returns the current offset within the file.
1670       */
1671 -    long tell() const;
1672 +    offset_t tell() const;
1673  
1674      /*!
1675       * Returns the length of the file.
1676       */
1677 -    long length();
1678 +    offset_t length();
1679  
1680      /*!
1681       * Truncates the file to a \a length.
1682       */
1683 -    void truncate(long length);
1684 +    void truncate(offset_t length);
1685  
1686    protected:
1687  
1688 diff --git a/taglib/toolkit/tiostream.h b/taglib/toolkit/tiostream.h
1689 index 1972d935..e089aef8 100644
1690 --- a/taglib/toolkit/tiostream.h
1691 +++ b/taglib/toolkit/tiostream.h
1692 @@ -110,7 +110,7 @@ namespace TagLib {
1693       * after the insertion point.
1694       */
1695      virtual void insert(const ByteVector &data,
1696 -                        unsigned long start = 0, unsigned long replace = 0) = 0;
1697 +                        offset_t start = 0, unsigned long replace = 0) = 0;
1698  
1699      /*!
1700       * Removes a block of the file starting a \a start and continuing for
1701 @@ -119,7 +119,7 @@ namespace TagLib {
1702       * \note This method is slow since it involves rewriting all of the file
1703       * after the removed portion.
1704       */
1705 -    virtual void removeBlock(unsigned long start = 0, unsigned long length = 0) = 0;
1706 +    virtual void removeBlock(offset_t start = 0, unsigned long length = 0) = 0;
1707  
1708      /*!
1709       * Returns true if the file is read only (or if the file can not be opened).
1710 @@ -138,7 +138,7 @@ namespace TagLib {
1711       *
1712       * \see Position
1713       */
1714 -    virtual void seek(long offset, Position p = Beginning) = 0;
1715 +    virtual void seek(offset_t offset, Position p = Beginning) = 0;
1716  
1717      /*!
1718       * Reset the end-of-stream and error flags on the stream.
1719 @@ -148,17 +148,17 @@ namespace TagLib {
1720      /*!
1721       * Returns the current offset within the stream.
1722       */
1723 -    virtual long tell() const = 0;
1724 +    virtual offset_t tell() const = 0;
1725  
1726      /*!
1727       * Returns the length of the stream.
1728       */
1729 -    virtual long length() = 0;
1730 +    virtual offset_t length() = 0;
1731  
1732      /*!
1733       * Truncates the stream to a \a length.
1734       */
1735 -    virtual void truncate(long length) = 0;
1736 +    virtual void truncate(offset_t length) = 0;
1737  
1738    private:
1739      IOStream(const IOStream &);
1740 diff --git a/taglib/trueaudio/trueaudiofile.cpp b/taglib/trueaudio/trueaudiofile.cpp
1741 index e1dd7b99..77b835ab 100644
1742 --- a/taglib/trueaudio/trueaudiofile.cpp
1743 +++ b/taglib/trueaudio/trueaudiofile.cpp
1744 @@ -63,10 +63,10 @@ public:
1745    }
1746  
1747    const ID3v2::FrameFactory *ID3v2FrameFactory;
1748 -  long ID3v2Location;
1749 +  offset_t ID3v2Location;
1750    long ID3v2OriginalSize;
1751  
1752 -  long ID3v1Location;
1753 +  offset_t ID3v1Location;
1754  
1755    TagUnion tag;
1756  
1757 @@ -290,7 +290,7 @@ void TrueAudio::File::read(bool readProperties)
1758  
1759    if(readProperties) {
1760  
1761 -    long streamLength;
1762 +    offset_t streamLength;
1763  
1764      if(d->ID3v1Location >= 0)
1765        streamLength = d->ID3v1Location;
1766 diff --git a/taglib/trueaudio/trueaudioproperties.cpp b/taglib/trueaudio/trueaudioproperties.cpp
1767 index 0aab2419..3a403848 100644
1768 --- a/taglib/trueaudio/trueaudioproperties.cpp
1769 +++ b/taglib/trueaudio/trueaudioproperties.cpp
1770 @@ -61,7 +61,7 @@ public:
1771  // public members
1772  ////////////////////////////////////////////////////////////////////////////////
1773  
1774 -TrueAudio::Properties::Properties(const ByteVector &data, long streamLength, ReadStyle style) :
1775 +TrueAudio::Properties::Properties(const ByteVector &data, offset_t streamLength, ReadStyle style) :
1776    AudioProperties(style),
1777    d(new PropertiesPrivate())
1778  {
1779 @@ -122,7 +122,7 @@ int TrueAudio::Properties::ttaVersion() const
1780  // private members
1781  ////////////////////////////////////////////////////////////////////////////////
1782  
1783 -void TrueAudio::Properties::read(const ByteVector &data, long streamLength)
1784 +void TrueAudio::Properties::read(const ByteVector &data, offset_t streamLength)
1785  {
1786    if(data.size() < 4) {
1787      debug("TrueAudio::Properties::read() -- data is too short.");
1788 diff --git a/taglib/trueaudio/trueaudioproperties.h b/taglib/trueaudio/trueaudioproperties.h
1789 index 490fea8e..9a72a7e3 100644
1790 --- a/taglib/trueaudio/trueaudioproperties.h
1791 +++ b/taglib/trueaudio/trueaudioproperties.h
1792 @@ -52,7 +52,7 @@ namespace TagLib {
1793         * Create an instance of TrueAudio::Properties with the data read from the
1794         * ByteVector \a data.
1795         */
1796 -      Properties(const ByteVector &data, long streamLength, ReadStyle style = Average);
1797 +      Properties(const ByteVector &data, offset_t streamLength, ReadStyle style = Average);
1798  
1799        /*!
1800         * Destroys this TrueAudio::Properties instance.
1801 @@ -120,7 +120,7 @@ namespace TagLib {
1802        Properties(const Properties &);
1803        Properties &operator=(const Properties &);
1804  
1805 -      void read(const ByteVector &data, long streamLength);
1806 +      void read(const ByteVector &data, offset_t streamLength);
1807  
1808        class PropertiesPrivate;
1809        PropertiesPrivate *d;
1810 diff --git a/taglib/wavpack/wavpackfile.cpp b/taglib/wavpack/wavpackfile.cpp
1811 index 291e9b88..bdca24ca 100644
1812 --- a/taglib/wavpack/wavpackfile.cpp
1813 +++ b/taglib/wavpack/wavpackfile.cpp
1814 @@ -61,10 +61,10 @@ public:
1815      delete properties;
1816    }
1817  
1818 -  long APELocation;
1819 +  offset_t APELocation;
1820    long APESize;
1821  
1822 -  long ID3v1Location;
1823 +  offset_t ID3v1Location;
1824  
1825    TagUnion tag;
1826  
1827 @@ -270,7 +270,7 @@ void WavPack::File::read(bool readProperties)
1828  
1829    if(readProperties) {
1830  
1831 -    long streamLength;
1832 +    offset_t streamLength;
1833  
1834      if(d->APELocation >= 0)
1835        streamLength = d->APELocation;
1836 diff --git a/taglib/wavpack/wavpackproperties.cpp b/taglib/wavpack/wavpackproperties.cpp
1837 index 1dd2a054..cc65f2d0 100644
1838 --- a/taglib/wavpack/wavpackproperties.cpp
1839 +++ b/taglib/wavpack/wavpackproperties.cpp
1840 @@ -66,14 +66,14 @@ public:
1841  // public members
1842  ////////////////////////////////////////////////////////////////////////////////
1843  
1844 -WavPack::Properties::Properties(const ByteVector &, long, ReadStyle style) :
1845 +WavPack::Properties::Properties(const ByteVector &, offset_t, ReadStyle style) :
1846    AudioProperties(style),
1847    d(new PropertiesPrivate())
1848  {
1849    debug("WavPack::Properties::Properties() -- This constructor is no longer used.");
1850  }
1851  
1852 -WavPack::Properties::Properties(File *file, long streamLength, ReadStyle style) :
1853 +WavPack::Properties::Properties(File *file, offset_t streamLength, ReadStyle style) :
1854    AudioProperties(style),
1855    d(new PropertiesPrivate())
1856  {
1857 @@ -257,9 +257,9 @@ namespace
1858  
1859  }  // namespace
1860  
1861 -void WavPack::Properties::read(File *file, long streamLength)
1862 +void WavPack::Properties::read(File *file, offset_t streamLength)
1863  {
1864 -  long offset = 0;
1865 +  offset_t offset = 0;
1866  
1867    while(true) {
1868      file->seek(offset);
1869 @@ -339,9 +339,9 @@ void WavPack::Properties::read(File *file, long streamLength)
1870    }
1871  }
1872  
1873 -unsigned int WavPack::Properties::seekFinalIndex(File *file, long streamLength)
1874 +unsigned int WavPack::Properties::seekFinalIndex(File *file, offset_t streamLength)
1875  {
1876 -  long offset = streamLength;
1877 +  offset_t offset = streamLength;
1878  
1879    while (offset >= 32) {
1880      offset = file->rfind("wvpk", offset - 4);
1881 diff --git a/taglib/wavpack/wavpackproperties.h b/taglib/wavpack/wavpackproperties.h
1882 index e1a481df..8360f9c9 100644
1883 --- a/taglib/wavpack/wavpackproperties.h
1884 +++ b/taglib/wavpack/wavpackproperties.h
1885 @@ -58,13 +58,13 @@ namespace TagLib {
1886         * \deprecated This constructor will be dropped in favor of the one below
1887         * in a future version.
1888         */
1889 -      TAGLIB_DEPRECATED Properties(const ByteVector &data, long streamLength,
1890 +      TAGLIB_DEPRECATED Properties(const ByteVector &data, offset_t streamLength,
1891                                     ReadStyle style = Average);
1892  
1893        /*!
1894         * Create an instance of WavPack::Properties.
1895         */
1896 -      Properties(File *file, long streamLength, ReadStyle style = Average);
1897 +      Properties(File *file, offset_t streamLength, ReadStyle style = Average);
1898  
1899        /*!
1900         * Destroys this WavPack::Properties instance.
1901 @@ -137,8 +137,8 @@ namespace TagLib {
1902        Properties(const Properties &);
1903        Properties &operator=(const Properties &);
1904  
1905 -      void read(File *file, long streamLength);
1906 -      unsigned int seekFinalIndex(File *file, long streamLength);
1907 +      void read(File *file, offset_t streamLength);
1908 +      unsigned int seekFinalIndex(File *file, offset_t streamLength);
1909  
1910        class PropertiesPrivate;
1911        PropertiesPrivate *d;
1912 diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp
1913 index 61a554c8..e5cd6156 100644
1914 --- a/taglib/xm/xmfile.cpp
1915 +++ b/taglib/xm/xmfile.cpp
1916 @@ -591,7 +591,7 @@ void XM::File::read(bool)
1917      unsigned int count = 4 + instrument.read(*this, instrumentHeaderSize - 4U);
1918      READ_ASSERT(count == std::min(instrumentHeaderSize, (unsigned long)instrument.size() + 4));
1919  
1920 -    long offset = 0;
1921 +    offset_t offset = 0;
1922      if(sampleCount > 0) {
1923        unsigned long sampleHeaderSize = 0;
1924        sumSampleCount += sampleCount;
1925 diff --git a/tests/plainfile.h b/tests/plainfile.h
1926 index 6147b56b..b42475f9 100644
1927 --- a/tests/plainfile.h
1928 +++ b/tests/plainfile.h
1929 @@ -41,7 +41,7 @@ public:
1930  
1931    ByteVector readAll() {
1932      seek(0, End);
1933 -    long end = tell();
1934 +    offset_t end = tell();
1935      seek(0);
1936      return readBlock(end);
1937    }
1938 diff --git a/tests/test_aiff.cpp b/tests/test_aiff.cpp
1939 index 0337729f..03cc545e 100644
1940 --- a/tests/test_aiff.cpp
1941 +++ b/tests/test_aiff.cpp
1942 @@ -141,8 +141,8 @@ public:
1943      CPPUNIT_ASSERT_EQUAL(String("Title1"), f.tag()->title());
1944  
1945      f.save();
1946 -    CPPUNIT_ASSERT_EQUAL(7030L, f.length());
1947 -    CPPUNIT_ASSERT_EQUAL(-1L, f.find("Title2"));
1948 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(7030), f.length());
1949 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(-1), f.find("Title2"));
1950    }
1951  
1952    void testFuzzedFile1()
1953 diff --git a/tests/test_asf.cpp b/tests/test_asf.cpp
1954 index 293abe30..ca13e16d 100644
1955 --- a/tests/test_asf.cpp
1956 +++ b/tests/test_asf.cpp
1957 @@ -389,10 +389,10 @@ public:
1958        ASF::File f(copy.fileName().c_str());
1959        f.tag()->setTitle(longText(128 * 1024));
1960        f.save();
1961 -      CPPUNIT_ASSERT_EQUAL(297578L, f.length());
1962 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(297578), f.length());
1963        f.tag()->setTitle(longText(16 * 1024));
1964        f.save();
1965 -      CPPUNIT_ASSERT_EQUAL(68202L, f.length());
1966 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(68202), f.length());
1967      }
1968    }
1969  
1970 diff --git a/tests/test_bytevectorstream.cpp b/tests/test_bytevectorstream.cpp
1971 index f8308c6d..b13ca61b 100644
1972 --- a/tests/test_bytevectorstream.cpp
1973 +++ b/tests/test_bytevectorstream.cpp
1974 @@ -117,7 +117,7 @@ public:
1975    {
1976      ByteVector v("abcdefghijklmnopqrstuvwxyz");
1977      ByteVectorStream stream(v);
1978 -    CPPUNIT_ASSERT_EQUAL(26L, stream.length());
1979 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(26), stream.length());
1980  
1981      stream.seek(-4, IOStream::End);
1982      CPPUNIT_ASSERT_EQUAL(ByteVector("w"), stream.readBlock(1));
1983 diff --git a/tests/test_file.cpp b/tests/test_file.cpp
1984 index ef8c1b10..a30ae4e2 100644
1985 --- a/tests/test_file.cpp
1986 +++ b/tests/test_file.cpp
1987 @@ -53,19 +53,19 @@ public:
1988      }
1989      {
1990        PlainFile file(name.c_str());
1991 -      CPPUNIT_ASSERT_EQUAL(10l, file.length());
1992 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(10), file.length());
1993  
1994 -      CPPUNIT_ASSERT_EQUAL(2l, file.find(ByteVector("23", 2)));
1995 -      CPPUNIT_ASSERT_EQUAL(2l, file.find(ByteVector("23", 2), 2));
1996 -      CPPUNIT_ASSERT_EQUAL(7l, file.find(ByteVector("23", 2), 3));
1997 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(2), file.find(ByteVector("23", 2)));
1998 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(2), file.find(ByteVector("23", 2), 2));
1999 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(7), file.find(ByteVector("23", 2), 3));
2000  
2001        file.seek(0);
2002        const ByteVector v = file.readBlock(file.length());
2003        CPPUNIT_ASSERT_EQUAL((unsigned int)10, v.size());
2004  
2005 -      CPPUNIT_ASSERT_EQUAL((long)v.find("23"),    file.find("23"));
2006 -      CPPUNIT_ASSERT_EQUAL((long)v.find("23", 2), file.find("23", 2));
2007 -      CPPUNIT_ASSERT_EQUAL((long)v.find("23", 3), file.find("23", 3));
2008 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(v.find("23")),    file.find("23"));
2009 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(v.find("23", 2)), file.find("23", 2));
2010 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(v.find("23", 3)), file.find("23", 3));
2011      }
2012    }
2013  
2014 @@ -81,19 +81,19 @@ public:
2015      }
2016      {
2017        PlainFile file(name.c_str());
2018 -      CPPUNIT_ASSERT_EQUAL(10l, file.length());
2019 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(10), file.length());
2020  
2021 -      CPPUNIT_ASSERT_EQUAL(7l, file.rfind(ByteVector("23", 2)));
2022 -      CPPUNIT_ASSERT_EQUAL(7l, file.rfind(ByteVector("23", 2), 7));
2023 -      CPPUNIT_ASSERT_EQUAL(2l, file.rfind(ByteVector("23", 2), 6));
2024 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(7), file.rfind(ByteVector("23", 2)));
2025 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(7), file.rfind(ByteVector("23", 2), 7));
2026 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(2), file.rfind(ByteVector("23", 2), 6));
2027  
2028        file.seek(0);
2029        const ByteVector v = file.readBlock(file.length());
2030        CPPUNIT_ASSERT_EQUAL((unsigned int)10, v.size());
2031  
2032 -      CPPUNIT_ASSERT_EQUAL((long)v.rfind("23"),    file.rfind("23"));
2033 -      CPPUNIT_ASSERT_EQUAL((long)v.rfind("23", 7), file.rfind("23", 7));
2034 -      CPPUNIT_ASSERT_EQUAL((long)v.rfind("23", 6), file.rfind("23", 6));
2035 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(v.rfind("23")),    file.rfind("23"));
2036 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(v.rfind("23", 7)), file.rfind("23", 7));
2037 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(v.rfind("23", 6)), file.rfind("23", 6));
2038      }
2039    }
2040  
2041 @@ -103,22 +103,22 @@ public:
2042      std::string name = copy.fileName();
2043  
2044      PlainFile f(name.c_str());
2045 -    CPPUNIT_ASSERT_EQUAL((long)0, f.tell());
2046 -    CPPUNIT_ASSERT_EQUAL((long)4328, f.length());
2047 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(0), f.tell());
2048 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4328), f.length());
2049  
2050      f.seek(100, File::Beginning);
2051 -    CPPUNIT_ASSERT_EQUAL((long)100, f.tell());
2052 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(100), f.tell());
2053      f.seek(100, File::Current);
2054 -    CPPUNIT_ASSERT_EQUAL((long)200, f.tell());
2055 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(200), f.tell());
2056      f.seek(-300, File::Current);
2057 -    CPPUNIT_ASSERT_EQUAL((long)200, f.tell());
2058 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(200), f.tell());
2059  
2060      f.seek(-100, File::End);
2061 -    CPPUNIT_ASSERT_EQUAL((long)4228, f.tell());
2062 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4228), f.tell());
2063      f.seek(-100, File::Current);
2064 -    CPPUNIT_ASSERT_EQUAL((long)4128, f.tell());
2065 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4128), f.tell());
2066      f.seek(300, File::Current);
2067 -    CPPUNIT_ASSERT_EQUAL((long)4428, f.tell());
2068 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4428), f.tell());
2069    }
2070  
2071    void testTruncate()
2072 @@ -128,18 +128,17 @@ public:
2073  
2074      {
2075        PlainFile f(name.c_str());
2076 -      CPPUNIT_ASSERT_EQUAL(4328L, f.length());
2077 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4328), f.length());
2078  
2079        f.truncate(2000);
2080 -      CPPUNIT_ASSERT_EQUAL(2000L, f.length());
2081 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(2000), f.length());
2082      }
2083      {
2084        PlainFile f(name.c_str());
2085 -      CPPUNIT_ASSERT_EQUAL(2000L, f.length());
2086 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(2000), f.length());
2087      }
2088    }
2089  
2090  };
2091  
2092  CPPUNIT_TEST_SUITE_REGISTRATION(TestFile);
2093 -
2094 diff --git a/tests/test_flac.cpp b/tests/test_flac.cpp
2095 index c83f1e90..d5352b3c 100644
2096 --- a/tests/test_flac.cpp
2097 +++ b/tests/test_flac.cpp
2098 @@ -91,8 +91,8 @@ public:
2099      {
2100        FLAC::File f(newname.c_str());
2101        CPPUNIT_ASSERT_EQUAL(String("The Artist"), f.tag()->artist());
2102 -      CPPUNIT_ASSERT_EQUAL(69L, f.find("Artist"));
2103 -      CPPUNIT_ASSERT_EQUAL(-1L, f.find("Artist", 70));
2104 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(69), f.find("Artist"));
2105 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(-1), f.find("Artist", 70));
2106      }
2107    }
2108  
2109 @@ -253,9 +253,9 @@ public:
2110      FLAC::File f(copy.fileName().c_str());
2111      f.ID3v2Tag(true)->setTitle("0123456789");
2112      f.save();
2113 -    CPPUNIT_ASSERT_EQUAL(5735L, f.length());
2114 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(5735), f.length());
2115      f.save();
2116 -    CPPUNIT_ASSERT_EQUAL(5735L, f.length());
2117 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(5735), f.length());
2118      CPPUNIT_ASSERT(f.find("fLaC") >= 0);
2119    }
2120  
2121 @@ -266,9 +266,9 @@ public:
2122      FLAC::File f(copy.fileName().c_str());
2123      f.xiphComment()->setTitle(longText(8 * 1024));
2124      f.save();
2125 -    CPPUNIT_ASSERT_EQUAL(12862L, f.length());
2126 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(12862), f.length());
2127      f.save();
2128 -    CPPUNIT_ASSERT_EQUAL(12862L, f.length());
2129 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(12862), f.length());
2130    }
2131  
2132    void testSaveMultipleValues()
2133 @@ -449,7 +449,7 @@ public:
2134      {
2135        FLAC::File f(copy.fileName().c_str());
2136        CPPUNIT_ASSERT(!f.hasID3v1Tag());
2137 -      CPPUNIT_ASSERT_EQUAL((long)4692, f.length());
2138 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4692), f.length());
2139  
2140        f.seek(0x0100);
2141        audioStream = f.readBlock(4436);
2142 @@ -457,7 +457,7 @@ public:
2143        f.ID3v1Tag(true)->setTitle("01234 56789 ABCDE FGHIJ");
2144        f.save();
2145        CPPUNIT_ASSERT(f.hasID3v1Tag());
2146 -      CPPUNIT_ASSERT_EQUAL((long)4820, f.length());
2147 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4820), f.length());
2148  
2149        f.seek(0x0100);
2150        CPPUNIT_ASSERT_EQUAL(audioStream, f.readBlock(4436));
2151 diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp
2152 index 36ddc436..9de2596d 100644
2153 --- a/tests/test_id3v2.cpp
2154 +++ b/tests/test_id3v2.cpp
2155 @@ -1553,14 +1553,14 @@ public:
2156      {
2157        MPEG::File f(newname.c_str());
2158        CPPUNIT_ASSERT(f.hasID3v2Tag());
2159 -      CPPUNIT_ASSERT_EQUAL(74789L, f.length());
2160 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(74789), f.length());
2161        f.ID3v2Tag()->setTitle("ABCDEFGHIJ");
2162        f.save(MPEG::File::ID3v2, File::StripOthers);
2163      }
2164      {
2165        MPEG::File f(newname.c_str());
2166        CPPUNIT_ASSERT(f.hasID3v2Tag());
2167 -      CPPUNIT_ASSERT_EQUAL(9263L, f.length());
2168 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(9263), f.length());
2169      }
2170    }
2171  
2172 @@ -1618,7 +1618,7 @@ public:
2173      {
2174        MPEG::File f(copy.fileName().c_str());
2175        CPPUNIT_ASSERT(f.hasID3v2Tag());
2176 -      CPPUNIT_ASSERT_EQUAL((long)3594, f.length());
2177 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(3594), f.length());
2178        CPPUNIT_ASSERT_EQUAL((unsigned int)1505, f.ID3v2Tag()->header()->completeTagSize());
2179        CPPUNIT_ASSERT_EQUAL(String("Artist A"), f.ID3v2Tag()->artist());
2180        CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
2181 @@ -1689,4 +1689,3 @@ public:
2182  };
2183  
2184  CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2);
2185 -
2186 diff --git a/tests/test_mp4.cpp b/tests/test_mp4.cpp
2187 index 2ead2bab..5c6a9cbb 100644
2188 --- a/tests/test_mp4.cpp
2189 +++ b/tests/test_mp4.cpp
2190 @@ -298,7 +298,7 @@ public:
2191  
2192        MP4::Atoms atoms(&f);
2193        MP4::Atom *moov = atoms.atoms[0];
2194 -      CPPUNIT_ASSERT_EQUAL(long(77), moov->length);
2195 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(77), moov->length);
2196  
2197        f.tag()->setItem("pgap", true);
2198        f.save();
2199 @@ -311,7 +311,7 @@ public:
2200        MP4::Atoms atoms(&f);
2201        MP4::Atom *moov = atoms.atoms[0];
2202        // original size + 'pgap' size + padding
2203 -      CPPUNIT_ASSERT_EQUAL(long(77 + 25 + 974), moov->length);
2204 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(77 + 25 + 974), moov->length);
2205      }
2206    }
2207  
2208 @@ -589,8 +589,8 @@ public:
2209      f.tag()->setTitle("0123456789");
2210      f.save();
2211      f.save();
2212 -    CPPUNIT_ASSERT_EQUAL(2862L, f.find("0123456789"));
2213 -    CPPUNIT_ASSERT_EQUAL(-1L, f.find("0123456789", 2863));
2214 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(2862), f.find("0123456789"));
2215 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(-1), f.find("0123456789", 2863));
2216    }
2217  
2218    void testWithZeroLengthAtom()
2219 diff --git a/tests/test_mpeg.cpp b/tests/test_mpeg.cpp
2220 index 03eb702b..bd3e316d 100644
2221 --- a/tests/test_mpeg.cpp
2222 +++ b/tests/test_mpeg.cpp
2223 @@ -119,10 +119,10 @@ public:
2224      CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
2225      CPPUNIT_ASSERT(!f.audioProperties()->xingHeader());
2226  
2227 -    const long last = f.lastFrameOffset();
2228 +    offset_t last = f.lastFrameOffset();
2229      const MPEG::Header lastHeader(&f, last, false);
2230  
2231 -    CPPUNIT_ASSERT_EQUAL(28213L, last);
2232 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(28213), last);
2233      CPPUNIT_ASSERT_EQUAL(209, lastHeader.frameLength());
2234    }
2235  
2236 @@ -258,20 +258,20 @@ public:
2237      {
2238        MPEG::File f(TEST_FILE_PATH_C("ape.mp3"));
2239        CPPUNIT_ASSERT(f.isValid());
2240 -      CPPUNIT_ASSERT_EQUAL((long)0x0000, f.firstFrameOffset());
2241 -      CPPUNIT_ASSERT_EQUAL((long)0x1FD6, f.lastFrameOffset());
2242 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(0x0000), f.firstFrameOffset());
2243 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(0x1FD6), f.lastFrameOffset());
2244      }
2245      {
2246        MPEG::File f(TEST_FILE_PATH_C("ape-id3v1.mp3"));
2247        CPPUNIT_ASSERT(f.isValid());
2248 -      CPPUNIT_ASSERT_EQUAL((long)0x0000, f.firstFrameOffset());
2249 -      CPPUNIT_ASSERT_EQUAL((long)0x1FD6, f.lastFrameOffset());
2250 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(0x0000), f.firstFrameOffset());
2251 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(0x1FD6), f.lastFrameOffset());
2252      }
2253      {
2254        MPEG::File f(TEST_FILE_PATH_C("ape-id3v2.mp3"));
2255        CPPUNIT_ASSERT(f.isValid());
2256 -      CPPUNIT_ASSERT_EQUAL((long)0x041A, f.firstFrameOffset());
2257 -      CPPUNIT_ASSERT_EQUAL((long)0x23F0, f.lastFrameOffset());
2258 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(0x041A), f.firstFrameOffset());
2259 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(0x23F0), f.lastFrameOffset());
2260      }
2261    }
2262  
2263 @@ -418,7 +418,7 @@ public:
2264        f.save();
2265        f.ID3v2Tag(true)->setTitle(std::string(4096, 'X').c_str());
2266        f.save();
2267 -      CPPUNIT_ASSERT_EQUAL(5141L, f.firstFrameOffset());
2268 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(5141), f.firstFrameOffset());
2269      }
2270    }
2271  
2272 @@ -430,7 +430,7 @@ public:
2273      f.ID3v2Tag(true)->setTitle("0123456789");
2274      f.save();
2275      f.save();
2276 -    CPPUNIT_ASSERT_EQUAL(-1L, f.find("ID3", 3));
2277 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(-1), f.find("ID3", 3));
2278    }
2279  
2280    void testRepeatedSave3()
2281 @@ -524,8 +524,8 @@ public:
2282        MPEG::File f(copy.fileName().c_str());
2283        CPPUNIT_ASSERT(f.isValid());
2284        CPPUNIT_ASSERT(f.hasID3v2Tag());
2285 -      CPPUNIT_ASSERT_EQUAL(2255L, f.firstFrameOffset());
2286 -      CPPUNIT_ASSERT_EQUAL(6015L, f.lastFrameOffset());
2287 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(2255), f.firstFrameOffset());
2288 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(6015), f.lastFrameOffset());
2289        CPPUNIT_ASSERT_EQUAL(String("Title A"), f.ID3v2Tag()->title());
2290        f.ID3v2Tag()->setTitle("Title B");
2291        f.save();
2292 diff --git a/tests/test_ogg.cpp b/tests/test_ogg.cpp
2293 index 0008429e..3c5e4ac6 100644
2294 --- a/tests/test_ogg.cpp
2295 +++ b/tests/test_ogg.cpp
2296 @@ -84,7 +84,7 @@ public:
2297      {
2298        Vorbis::File f(newname.c_str());
2299        CPPUNIT_ASSERT(f.isValid());
2300 -      CPPUNIT_ASSERT_EQUAL(136383L, f.length());
2301 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(136383), f.length());
2302        CPPUNIT_ASSERT_EQUAL(19, f.lastPageHeader()->pageSequenceNumber());
2303        CPPUNIT_ASSERT_EQUAL(30U, f.packet(0).size());
2304        CPPUNIT_ASSERT_EQUAL(131127U, f.packet(1).size());
2305 @@ -100,7 +100,7 @@ public:
2306      {
2307        Vorbis::File f(newname.c_str());
2308        CPPUNIT_ASSERT(f.isValid());
2309 -      CPPUNIT_ASSERT_EQUAL(4370L, f.length());
2310 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4370), f.length());
2311        CPPUNIT_ASSERT_EQUAL(3, f.lastPageHeader()->pageSequenceNumber());
2312        CPPUNIT_ASSERT_EQUAL(30U, f.packet(0).size());
2313        CPPUNIT_ASSERT_EQUAL(60U, f.packet(1).size());
2314 diff --git a/tests/test_oggflac.cpp b/tests/test_oggflac.cpp
2315 index 1d00d123..b8fde4a9 100644
2316 --- a/tests/test_oggflac.cpp
2317 +++ b/tests/test_oggflac.cpp
2318 @@ -62,7 +62,7 @@ public:
2319        CPPUNIT_ASSERT_EQUAL(String("The Artist"), f.tag()->artist());
2320  
2321        f.seek(0, File::End);
2322 -      CPPUNIT_ASSERT_EQUAL(9134L, f.tell());
2323 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(9134), f.tell());
2324      }
2325    }
2326  
2327 @@ -87,7 +87,7 @@ public:
2328      {
2329        Ogg::FLAC::File f(newname.c_str());
2330        CPPUNIT_ASSERT(f.isValid());
2331 -      CPPUNIT_ASSERT_EQUAL(141141L, f.length());
2332 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(141141), f.length());
2333        CPPUNIT_ASSERT_EQUAL(21, f.lastPageHeader()->pageSequenceNumber());
2334        CPPUNIT_ASSERT_EQUAL(51U, f.packet(0).size());
2335        CPPUNIT_ASSERT_EQUAL(131126U, f.packet(1).size());
2336 @@ -104,7 +104,7 @@ public:
2337      {
2338        Ogg::FLAC::File f(newname.c_str());
2339        CPPUNIT_ASSERT(f.isValid());
2340 -      CPPUNIT_ASSERT_EQUAL(9128L, f.length());
2341 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(9128), f.length());
2342        CPPUNIT_ASSERT_EQUAL(5, f.lastPageHeader()->pageSequenceNumber());
2343        CPPUNIT_ASSERT_EQUAL(51U, f.packet(0).size());
2344        CPPUNIT_ASSERT_EQUAL(59U, f.packet(1).size());
2345 diff --git a/tests/test_opus.cpp b/tests/test_opus.cpp
2346 index 9a49d239..d172e479 100644
2347 --- a/tests/test_opus.cpp
2348 +++ b/tests/test_opus.cpp
2349 @@ -102,7 +102,7 @@ public:
2350      {
2351        Ogg::Opus::File f(newname.c_str());
2352        CPPUNIT_ASSERT(f.isValid());
2353 -      CPPUNIT_ASSERT_EQUAL(167534L, f.length());
2354 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(167534), f.length());
2355        CPPUNIT_ASSERT_EQUAL(27, f.lastPageHeader()->pageSequenceNumber());
2356        CPPUNIT_ASSERT_EQUAL(19U, f.packet(0).size());
2357        CPPUNIT_ASSERT_EQUAL(131380U, f.packet(1).size());
2358 @@ -119,7 +119,7 @@ public:
2359      {
2360        Ogg::Opus::File f(newname.c_str());
2361        CPPUNIT_ASSERT(f.isValid());
2362 -      CPPUNIT_ASSERT_EQUAL(35521L, f.length());
2363 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(35521), f.length());
2364        CPPUNIT_ASSERT_EQUAL(11, f.lastPageHeader()->pageSequenceNumber());
2365        CPPUNIT_ASSERT_EQUAL(19U, f.packet(0).size());
2366        CPPUNIT_ASSERT_EQUAL(313U, f.packet(1).size());
2367 diff --git a/tests/test_riff.cpp b/tests/test_riff.cpp
2368 index f9a20dfb..0aeebde3 100644
2369 --- a/tests/test_riff.cpp
2370 +++ b/tests/test_riff.cpp
2371 @@ -40,7 +40,7 @@ public:
2372    PublicRIFF(FileName file) : RIFF::File(file, BigEndian) {};
2373    unsigned int riffSize() { return RIFF::File::riffSize(); };
2374    unsigned int chunkCount() { return RIFF::File::chunkCount(); };
2375 -  unsigned int chunkOffset(unsigned int i) { return RIFF::File::chunkOffset(i); };
2376 +  offset_t chunkOffset(unsigned int i) { return RIFF::File::chunkOffset(i); };
2377    unsigned int chunkPadding(unsigned int i) { return RIFF::File::chunkPadding(i); };
2378    unsigned int chunkDataSize(unsigned int i) { return RIFF::File::chunkDataSize(i); };
2379    ByteVector chunkName(unsigned int i) { return RIFF::File::chunkName(i); };
2380 @@ -78,7 +78,7 @@ public:
2381      {
2382        PublicRIFF f(filename.c_str());
2383        CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(2));
2384 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(0x1728 + 8), f.chunkOffset(2));
2385 +      CPPUNIT_ASSERT_EQUAL((offset_t)(0x1728 + 8), f.chunkOffset(2));
2386  
2387        f.setChunkData("TEST", "foo");
2388      }
2389 @@ -87,7 +87,7 @@ public:
2390        CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(2));
2391        CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), f.chunkData(2));
2392        CPPUNIT_ASSERT_EQUAL((unsigned int)(3), f.chunkDataSize(2));
2393 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(0x1728 + 8), f.chunkOffset(2));
2394 +      CPPUNIT_ASSERT_EQUAL((offset_t)(0x1728 + 8), f.chunkOffset(2));
2395  
2396        f.setChunkData("SSND", "abcd");
2397  
2398 @@ -120,18 +120,18 @@ public:
2399  
2400      {
2401        PublicRIFF f(filename.c_str());
2402 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(0xff0 + 8), f.chunkOffset(2));
2403 +      CPPUNIT_ASSERT_EQUAL((offset_t)(0xff0 + 8), f.chunkOffset(2));
2404        CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2));
2405        CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2));
2406        CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2));
2407 -      CPPUNIT_ASSERT_EQUAL(long(4400), f.length());
2408 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4400), f.length());
2409        CPPUNIT_ASSERT_EQUAL((unsigned int)(4399 - 8), f.riffSize());
2410        f.setChunkData("TEST", "abcd");
2411 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(4088), f.chunkOffset(2));
2412 +      CPPUNIT_ASSERT_EQUAL((offset_t)(4088), f.chunkOffset(2));
2413        CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2));
2414        CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2));
2415        CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2));
2416 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(4408), f.chunkOffset(3));
2417 +      CPPUNIT_ASSERT_EQUAL((offset_t)(4408), f.chunkOffset(3));
2418        CPPUNIT_ASSERT_EQUAL((unsigned int)(4), f.chunkDataSize(3));
2419        CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3));
2420        CPPUNIT_ASSERT_EQUAL((unsigned int)(0), f.chunkPadding(3));
2421 @@ -139,15 +139,15 @@ public:
2422      }
2423      {
2424        PublicRIFF f(filename.c_str());
2425 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(4088), f.chunkOffset(2));
2426 +      CPPUNIT_ASSERT_EQUAL((offset_t)(4088), f.chunkOffset(2));
2427        CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2));
2428        CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2));
2429        CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2));
2430 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(4408), f.chunkOffset(3));
2431 +      CPPUNIT_ASSERT_EQUAL((offset_t)(4408), f.chunkOffset(3));
2432        CPPUNIT_ASSERT_EQUAL((unsigned int)(4), f.chunkDataSize(3));
2433        CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3));
2434        CPPUNIT_ASSERT_EQUAL((unsigned int)(0), f.chunkPadding(3));
2435 -      CPPUNIT_ASSERT_EQUAL(long(4412), f.length());
2436 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4412), f.length());
2437      }
2438    }
2439  
2440 @@ -158,18 +158,18 @@ public:
2441  
2442      {
2443        PublicRIFF f(filename.c_str());
2444 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(0xff0 + 8), f.chunkOffset(2));
2445 +      CPPUNIT_ASSERT_EQUAL((offset_t)(0xff0 + 8), f.chunkOffset(2));
2446        CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2));
2447        CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2));
2448        CPPUNIT_ASSERT_EQUAL((unsigned int)(0), f.chunkPadding(2));
2449 -      CPPUNIT_ASSERT_EQUAL(long(4399), f.length());
2450 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4399), f.length());
2451        CPPUNIT_ASSERT_EQUAL((unsigned int)(4399 - 8), f.riffSize());
2452        f.setChunkData("TEST", "abcd");
2453 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(4088), f.chunkOffset(2));
2454 +      CPPUNIT_ASSERT_EQUAL((offset_t)(4088), f.chunkOffset(2));
2455        CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2));
2456        CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2));
2457        CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2));
2458 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(4408), f.chunkOffset(3));
2459 +      CPPUNIT_ASSERT_EQUAL((offset_t)(4408), f.chunkOffset(3));
2460        CPPUNIT_ASSERT_EQUAL((unsigned int)(4), f.chunkDataSize(3));
2461        CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3));
2462        CPPUNIT_ASSERT_EQUAL((unsigned int)(0), f.chunkPadding(3));
2463 @@ -177,15 +177,15 @@ public:
2464      }
2465      {
2466        PublicRIFF f(filename.c_str());
2467 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(4088), f.chunkOffset(2));
2468 +      CPPUNIT_ASSERT_EQUAL((offset_t)(4088), f.chunkOffset(2));
2469        CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2));
2470        CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2));
2471        CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2));
2472 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(4408), f.chunkOffset(3));
2473 +      CPPUNIT_ASSERT_EQUAL((offset_t)(4408), f.chunkOffset(3));
2474        CPPUNIT_ASSERT_EQUAL((unsigned int)(4), f.chunkDataSize(3));
2475        CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3));
2476        CPPUNIT_ASSERT_EQUAL((unsigned int)(0), f.chunkPadding(3));
2477 -      CPPUNIT_ASSERT_EQUAL(long(4412), f.length());
2478 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4412), f.length());
2479      }
2480    }
2481  
2482 @@ -196,18 +196,18 @@ public:
2483  
2484      {
2485        PublicRIFF f(filename.c_str());
2486 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(0xff0 + 8), f.chunkOffset(2));
2487 +      CPPUNIT_ASSERT_EQUAL((offset_t)(0xff0 + 8), f.chunkOffset(2));
2488        CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2));
2489        CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2));
2490        CPPUNIT_ASSERT_EQUAL((unsigned int)(0), f.chunkPadding(2));
2491 -      CPPUNIT_ASSERT_EQUAL(long(4399), f.length());
2492 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4399), f.length());
2493        CPPUNIT_ASSERT_EQUAL((unsigned int)(4399 - 8), f.riffSize());
2494        f.setChunkData("TEST", "abc");
2495 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(4088), f.chunkOffset(2));
2496 +      CPPUNIT_ASSERT_EQUAL((offset_t)(4088), f.chunkOffset(2));
2497        CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2));
2498        CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2));
2499        CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2));
2500 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(4408), f.chunkOffset(3));
2501 +      CPPUNIT_ASSERT_EQUAL((offset_t)(4408), f.chunkOffset(3));
2502        CPPUNIT_ASSERT_EQUAL((unsigned int)(3), f.chunkDataSize(3));
2503        CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3));
2504        CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(3));
2505 @@ -215,15 +215,15 @@ public:
2506      }
2507      {
2508        PublicRIFF f(filename.c_str());
2509 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(4088), f.chunkOffset(2));
2510 +      CPPUNIT_ASSERT_EQUAL((offset_t)(4088), f.chunkOffset(2));
2511        CPPUNIT_ASSERT_EQUAL((unsigned int)(311), f.chunkDataSize(2));
2512        CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(2));
2513        CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(2));
2514 -      CPPUNIT_ASSERT_EQUAL((unsigned int)(4408), f.chunkOffset(3));
2515 +      CPPUNIT_ASSERT_EQUAL((offset_t)(4408), f.chunkOffset(3));
2516        CPPUNIT_ASSERT_EQUAL((unsigned int)(3), f.chunkDataSize(3));
2517        CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(3));
2518        CPPUNIT_ASSERT_EQUAL((unsigned int)(1), f.chunkPadding(3));
2519 -      CPPUNIT_ASSERT_EQUAL(long(4412), f.length());
2520 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(4412), f.length());
2521      }
2522    }
2523  
2524 @@ -235,21 +235,21 @@ public:
2525      PublicRIFF f(filename.c_str());
2526  
2527      CPPUNIT_ASSERT_EQUAL(5928U, f.riffSize());
2528 -    CPPUNIT_ASSERT_EQUAL(5936L, f.length());
2529 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(5936), f.length());
2530      CPPUNIT_ASSERT_EQUAL(ByteVector("COMM"), f.chunkName(0));
2531 -    CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0));
2532 +    CPPUNIT_ASSERT_EQUAL((offset_t)(0x000C + 8), f.chunkOffset(0));
2533      CPPUNIT_ASSERT_EQUAL(ByteVector("SSND"), f.chunkName(1));
2534 -    CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0026 + 8), f.chunkOffset(1));
2535 +    CPPUNIT_ASSERT_EQUAL((offset_t)(0x0026 + 8), f.chunkOffset(1));
2536      CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.chunkName(2));
2537 -    CPPUNIT_ASSERT_EQUAL((unsigned int)(0x1728 + 8), f.chunkOffset(2));
2538 +    CPPUNIT_ASSERT_EQUAL((offset_t)(0x1728 + 8), f.chunkOffset(2));
2539  
2540      const ByteVector data(0x400, ' ');
2541      f.setChunkData("SSND", data);
2542      CPPUNIT_ASSERT_EQUAL(1070U, f.riffSize());
2543 -    CPPUNIT_ASSERT_EQUAL(1078L, f.length());
2544 -    CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0));
2545 -    CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0026 + 8), f.chunkOffset(1));
2546 -    CPPUNIT_ASSERT_EQUAL((unsigned int)(0x042E + 8), f.chunkOffset(2));
2547 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(1078), f.length());
2548 +    CPPUNIT_ASSERT_EQUAL((offset_t)(0x000C + 8), f.chunkOffset(0));
2549 +    CPPUNIT_ASSERT_EQUAL((offset_t)(0x0026 + 8), f.chunkOffset(1));
2550 +    CPPUNIT_ASSERT_EQUAL((offset_t)(0x042E + 8), f.chunkOffset(2));
2551  
2552      f.seek(f.chunkOffset(0) - 8);
2553      CPPUNIT_ASSERT_EQUAL(ByteVector("COMM"), f.readBlock(4));
2554 @@ -260,10 +260,10 @@ public:
2555  
2556      f.setChunkData(0, data);
2557      CPPUNIT_ASSERT_EQUAL(2076U, f.riffSize());
2558 -    CPPUNIT_ASSERT_EQUAL(2084L, f.length());
2559 -    CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0));
2560 -    CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0414 + 8), f.chunkOffset(1));
2561 -    CPPUNIT_ASSERT_EQUAL((unsigned int)(0x081C + 8), f.chunkOffset(2));
2562 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(2084), f.length());
2563 +    CPPUNIT_ASSERT_EQUAL((offset_t)(0x000C + 8), f.chunkOffset(0));
2564 +    CPPUNIT_ASSERT_EQUAL((offset_t)(0x0414 + 8), f.chunkOffset(1));
2565 +    CPPUNIT_ASSERT_EQUAL((offset_t)(0x081C + 8), f.chunkOffset(2));
2566  
2567      f.seek(f.chunkOffset(0) - 8);
2568      CPPUNIT_ASSERT_EQUAL(ByteVector("COMM"), f.readBlock(4));
2569 @@ -274,9 +274,9 @@ public:
2570  
2571      f.removeChunk("SSND");
2572      CPPUNIT_ASSERT_EQUAL(1044U, f.riffSize());
2573 -    CPPUNIT_ASSERT_EQUAL(1052L, f.length());
2574 -    CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0));
2575 -    CPPUNIT_ASSERT_EQUAL((unsigned int)(0x0414 + 8), f.chunkOffset(1));
2576 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(1052), f.length());
2577 +    CPPUNIT_ASSERT_EQUAL((offset_t)(0x000C + 8), f.chunkOffset(0));
2578 +    CPPUNIT_ASSERT_EQUAL((offset_t)(0x0414 + 8), f.chunkOffset(1));
2579  
2580      f.seek(f.chunkOffset(0) - 8);
2581      CPPUNIT_ASSERT_EQUAL(ByteVector("COMM"), f.readBlock(4));
2582 @@ -285,8 +285,8 @@ public:
2583  
2584      f.removeChunk(0);
2585      CPPUNIT_ASSERT_EQUAL(12U, f.riffSize());
2586 -    CPPUNIT_ASSERT_EQUAL(20L, f.length());
2587 -    CPPUNIT_ASSERT_EQUAL((unsigned int)(0x000C + 8), f.chunkOffset(0));
2588 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(20), f.length());
2589 +    CPPUNIT_ASSERT_EQUAL((offset_t)(0x000C + 8), f.chunkOffset(0));
2590  
2591      f.seek(f.chunkOffset(0) - 8);
2592      CPPUNIT_ASSERT_EQUAL(ByteVector("TEST"), f.readBlock(4));
2593 @@ -295,4 +295,3 @@ public:
2594  };
2595  
2596  CPPUNIT_TEST_SUITE_REGISTRATION(TestRIFF);
2597 -
2598 diff --git a/tests/test_speex.cpp b/tests/test_speex.cpp
2599 index 1f5bb754..c8268c21 100644
2600 --- a/tests/test_speex.cpp
2601 +++ b/tests/test_speex.cpp
2602 @@ -67,7 +67,7 @@ public:
2603      {
2604        Ogg::Speex::File f(newname.c_str());
2605        CPPUNIT_ASSERT(f.isValid());
2606 -      CPPUNIT_ASSERT_EQUAL(156330L, f.length());
2607 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(156330), f.length());
2608        CPPUNIT_ASSERT_EQUAL(23, f.lastPageHeader()->pageSequenceNumber());
2609        CPPUNIT_ASSERT_EQUAL(80U, f.packet(0).size());
2610        CPPUNIT_ASSERT_EQUAL(131116U, f.packet(1).size());
2611 @@ -84,7 +84,7 @@ public:
2612      {
2613        Ogg::Speex::File f(newname.c_str());
2614        CPPUNIT_ASSERT(f.isValid());
2615 -      CPPUNIT_ASSERT_EQUAL(24317L, f.length());
2616 +      CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(24317), f.length());
2617        CPPUNIT_ASSERT_EQUAL(7, f.lastPageHeader()->pageSequenceNumber());
2618        CPPUNIT_ASSERT_EQUAL(80U, f.packet(0).size());
2619        CPPUNIT_ASSERT_EQUAL(49U, f.packet(1).size());
2620 diff --git a/tests/test_wav.cpp b/tests/test_wav.cpp
2621 index 61081393..55d71e0b 100644
2622 --- a/tests/test_wav.cpp
2623 +++ b/tests/test_wav.cpp
2624 @@ -268,7 +268,7 @@ public:
2625      ScopedFileCopy copy("duplicate_tags", ".wav");
2626  
2627      RIFF::WAV::File f(copy.fileName().c_str());
2628 -    CPPUNIT_ASSERT_EQUAL(17052L, f.length());
2629 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(17052), f.length());
2630  
2631      // duplicate_tags.wav has duplicate ID3v2/INFO tags.
2632      // title() returns "Title2" if can't skip the second tag.
2633 @@ -280,8 +280,8 @@ public:
2634      CPPUNIT_ASSERT_EQUAL(String("Title1"), f.InfoTag()->title());
2635  
2636      f.save();
2637 -    CPPUNIT_ASSERT_EQUAL(15898L, f.length());
2638 -    CPPUNIT_ASSERT_EQUAL(-1L, f.find("Title2"));
2639 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(15898), f.length());
2640 +    CPPUNIT_ASSERT_EQUAL(static_cast<offset_t>(-1), f.find("Title2"));
2641    }
2642  
2643    void testFuzzedFile1()