diff --git a/common/FileReader.h b/common/FileReader.h index 3cb06144def..0e095bb43b2 100644 --- a/common/FileReader.h +++ b/common/FileReader.h @@ -157,7 +157,6 @@ class FileReader public: using pos_type = typename traits_type::pos_type; - using off_t = pos_type; using data_type = typename traits_type::data_type; using ref_data_type = typename traits_type::ref_data_type; @@ -382,19 +381,19 @@ class FileReader using ChunkList = mpt::IO::FileReader::ChunkList; template - Item ReadNextChunk(off_t alignment) + Item ReadNextChunk(pos_type alignment) { return mpt::IO::FileReader::ReadNextChunk(*this, alignment); } template - ChunkList ReadChunks(off_t alignment) + ChunkList ReadChunks(pos_type alignment) { return mpt::IO::FileReader::ReadChunks(*this, alignment); } template - ChunkList ReadChunksUntil(off_t alignment, decltype(T().GetID()) stopAtID) + ChunkList ReadChunksUntil(pos_type alignment, decltype(T().GetID()) stopAtID) { return mpt::IO::FileReader::ReadChunksUntil(*this, alignment, stopAtID); } diff --git a/soundlib/BitReader.h b/soundlib/BitReader.h index 30feb8dab53..8e1b3fdf7ca 100644 --- a/soundlib/BitReader.h +++ b/soundlib/BitReader.h @@ -25,7 +25,8 @@ OPENMPT_NAMESPACE_BEGIN class BitReader : private FileReader { protected: - off_t m_bufPos = 0, m_bufSize = 0; + pos_type m_bufPos = 0; + pos_type m_bufSize = 0; uint32 bitBuf = 0; // Current bit buffer int m_bitNum = 0; // Currently available number of bits std::byte buffer[mpt::IO::BUFFERSIZE_TINY]{}; @@ -43,12 +44,12 @@ class BitReader : private FileReader BitReader(const FileCursor &other) : FileReader(other) { } BitReader(FileCursor &&other) : FileReader(std::move(other)) { } - off_t GetLength() const + pos_type GetLength() const { return FileReader::GetLength(); } - off_t GetPosition() const + pos_type GetPosition() const { return FileReader::GetPosition() - m_bufSize + m_bufPos; } diff --git a/soundlib/ContainerPP20.cpp b/soundlib/ContainerPP20.cpp index 5dc59066f71..35a11053778 100644 --- a/soundlib/ContainerPP20.cpp +++ b/soundlib/ContainerPP20.cpp @@ -181,7 +181,7 @@ bool UnpackPP20(std::vector &containerItems, FileReader &file, Co containerItems.back().data_cache = std::make_unique >(); std::vector & unpackedData = *(containerItems.back().data_cache); - FileReader::off_t length = file.GetLength(); + FileReader::pos_type length = file.GetLength(); if(!mpt::in_range(length)) return false; // Length word must be aligned if((length % 2u) != 0) diff --git a/soundlib/Load_669.cpp b/soundlib/Load_669.cpp index d3afbffe658..03daa0ac1fb 100644 --- a/soundlib/Load_669.cpp +++ b/soundlib/Load_669.cpp @@ -130,7 +130,7 @@ bool CSoundFile::Read669(FileReader &file, ModLoadingFlags loadFlags) return true; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } diff --git a/soundlib/Load_amf.cpp b/soundlib/Load_amf.cpp index bccb720b456..d135373dced 100644 --- a/soundlib/Load_amf.cpp +++ b/soundlib/Load_amf.cpp @@ -116,7 +116,7 @@ bool CSoundFile::ReadAMF_Asylum(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } @@ -644,7 +644,7 @@ bool CSoundFile::ReadAMF_DSMI(FileReader &file, ModLoadingFlags loadFlags) // Setup Order List Order().resize(fileHeader.numOrders); std::vector patternLength; - const FileReader::off_t trackStartPos = file.GetPosition() + (fileSignature.version >= 14 ? 2 : 0); + const FileReader::pos_type trackStartPos = file.GetPosition() + (fileSignature.version >= 14 ? 2 : 0); if(fileSignature.version >= 14) { patternLength.resize(fileHeader.numOrders); diff --git a/soundlib/Load_ams.cpp b/soundlib/Load_ams.cpp index 9420250f407..4b57d3c5928 100644 --- a/soundlib/Load_ams.cpp +++ b/soundlib/Load_ams.cpp @@ -387,7 +387,7 @@ bool CSoundFile::ReadAMS(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } @@ -765,7 +765,7 @@ bool CSoundFile::ReadAMS2(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } diff --git a/soundlib/Load_c67.cpp b/soundlib/Load_c67.cpp index b02415b6b45..495087deb5d 100644 --- a/soundlib/Load_c67.cpp +++ b/soundlib/Load_c67.cpp @@ -137,7 +137,7 @@ bool CSoundFile::ReadC67(FileReader &file, ModLoadingFlags loadFlags) return true; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } diff --git a/soundlib/Load_dsym.cpp b/soundlib/Load_dsym.cpp index 7d8e3a18dd0..9377d3ac3a0 100644 --- a/soundlib/Load_dsym.cpp +++ b/soundlib/Load_dsym.cpp @@ -125,7 +125,7 @@ static std::vector DecompressDSymLZW(FileReader &file, uint32 size) MPT_ASSERT(output.size() == size); // Align length to 4 bytes - file.Seek(startPos + ((bitFile.GetPosition() - startPos + 3u) & ~FileReader::off_t(3))); + file.Seek(startPos + ((bitFile.GetPosition() - startPos + 3u) & ~FileReader::pos_type(3))); return output; } @@ -183,7 +183,7 @@ static std::vector DecompressDSymSigmaDelta(FileReader &file, uint32 } // Align length to 4 bytes - file.Seek(startPos + ((bitFile.GetPosition() - startPos + 3u) & ~FileReader::off_t(3))); + file.Seek(startPos + ((bitFile.GetPosition() - startPos + 3u) & ~FileReader::pos_type(3))); return output; } @@ -230,7 +230,7 @@ bool CSoundFile::ReadDSym(FileReader &file, ModLoadingFlags loadFlags) file.Rewind(); if(!file.ReadStruct(fileHeader) || !fileHeader.Validate()) return false; - if(!file.CanRead(mpt::saturate_cast(fileHeader.GetHeaderMinimumAdditionalSize()))) + if(!file.CanRead(mpt::saturate_cast(fileHeader.GetHeaderMinimumAdditionalSize()))) return false; if(loadFlags == onlyVerifyHeader) return true; diff --git a/soundlib/Load_far.cpp b/soundlib/Load_far.cpp index f43c0a84ef8..8b492b0f207 100644 --- a/soundlib/Load_far.cpp +++ b/soundlib/Load_far.cpp @@ -152,7 +152,7 @@ bool CSoundFile::ReadFAR(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } diff --git a/soundlib/Load_fmt.cpp b/soundlib/Load_fmt.cpp index 2b8a83a1f62..17da5ff17d5 100644 --- a/soundlib/Load_fmt.cpp +++ b/soundlib/Load_fmt.cpp @@ -80,7 +80,7 @@ bool CSoundFile::ReadFMT(FileReader &file, ModLoadingFlags loadFlags) return false; if(!ValidateHeader(fileHeader)) return false; - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) return false; if(loadFlags == onlyVerifyHeader) return true; diff --git a/soundlib/Load_gt2.cpp b/soundlib/Load_gt2.cpp index ede7df4b934..a7015ff17ab 100644 --- a/soundlib/Load_gt2.cpp +++ b/soundlib/Load_gt2.cpp @@ -525,7 +525,7 @@ bool CSoundFile::ReadGTK(FileReader &file, ModLoadingFlags loadFlags) return false; if(!fileHeader.Validate()) return false; - if(!file.CanRead(mpt::saturate_cast(fileHeader.GetHeaderMinimumAdditionalSize()))) + if(!file.CanRead(mpt::saturate_cast(fileHeader.GetHeaderMinimumAdditionalSize()))) return false; if(loadFlags == onlyVerifyHeader) return true; @@ -1202,7 +1202,7 @@ bool CSoundFile::ReadGT2(FileReader &file, ModLoadingFlags loadFlags) return false; if(!fileHeader.Validate()) return false; - if(!file.CanRead(mpt::saturate_cast(fileHeader.GetHeaderMinimumAdditionalSize()))) + if(!file.CanRead(mpt::saturate_cast(fileHeader.GetHeaderMinimumAdditionalSize()))) return false; if(loadFlags == onlyVerifyHeader) return true; diff --git a/soundlib/Load_imf.cpp b/soundlib/Load_imf.cpp index f5294ce93f0..cf76deca7db 100644 --- a/soundlib/Load_imf.cpp +++ b/soundlib/Load_imf.cpp @@ -428,7 +428,7 @@ bool CSoundFile::ReadIMF(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } diff --git a/soundlib/Load_it.cpp b/soundlib/Load_it.cpp index 8d940f612a0..ad319c6272b 100644 --- a/soundlib/Load_it.cpp +++ b/soundlib/Load_it.cpp @@ -302,7 +302,7 @@ size_t CSoundFile::ITInstrToMPT(FileReader &file, ModInstrument &ins, uint16 trk } } else { - const FileReader::off_t offset = file.GetPosition(); + const FileReader::pos_type offset = file.GetPosition(); // Try loading extended instrument... instSize will differ between normal and extended instruments. ITInstrumentEx instrumentHeader; @@ -421,7 +421,7 @@ bool CSoundFile::ReadIT(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } @@ -776,7 +776,7 @@ bool CSoundFile::ReadIT(FileReader &file, ModLoadingFlags loadFlags) // In order to properly compute the position, in file, of eventual extended settings // such as "attack" we need to keep the "real" size of the last sample as those extra // setting will follow this sample in the file - FileReader::off_t lastSampleOffset = 0; + FileReader::pos_type lastSampleOffset = 0; if(fileHeader.smpnum > 0) { lastSampleOffset = smpPos[fileHeader.smpnum - 1] + sizeof(ITSample); diff --git a/soundlib/Load_itp.cpp b/soundlib/Load_itp.cpp index fe131fe582c..198e1d104e5 100644 --- a/soundlib/Load_itp.cpp +++ b/soundlib/Load_itp.cpp @@ -157,7 +157,7 @@ bool CSoundFile::ReadITP(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(hdr)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(hdr)))) { return false; } diff --git a/soundlib/Load_med.cpp b/soundlib/Load_med.cpp index 4ff1e48d88e..2a4d01842c5 100644 --- a/soundlib/Load_med.cpp +++ b/soundlib/Load_med.cpp @@ -714,7 +714,7 @@ bool CSoundFile::ReadMED(FileReader &file, ModLoadingFlags loadFlags) return false; if(!ValidateHeader(fileHeader)) return false; - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) return false; if(loadFlags == onlyVerifyHeader) return true; diff --git a/soundlib/Load_mo3.cpp b/soundlib/Load_mo3.cpp index e55202d2ec3..178141cdf88 100644 --- a/soundlib/Load_mo3.cpp +++ b/soundlib/Load_mo3.cpp @@ -667,11 +667,11 @@ static int VorbisfileFilereaderSeek(void *datasource, ogg_int64_t offset, int wh switch(whence) { case SEEK_SET: - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - return file.Seek(mpt::saturate_cast(offset)) ? 0 : -1; + return file.Seek(mpt::saturate_cast(offset)) ? 0 : -1; case SEEK_CUR: if(offset < 0) @@ -680,31 +680,31 @@ static int VorbisfileFilereaderSeek(void *datasource, ogg_int64_t offset, int wh { return -1; } - if(!mpt::in_range(0 - offset)) + if(!mpt::in_range(0 - offset)) { return -1; } - return file.SkipBack(mpt::saturate_cast(0 - offset)) ? 0 : -1; + return file.SkipBack(mpt::saturate_cast(0 - offset)) ? 0 : -1; } else { - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - return file.Skip(mpt::saturate_cast(offset)) ? 0 : -1; + return file.Skip(mpt::saturate_cast(offset)) ? 0 : -1; } break; case SEEK_END: - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - if(!mpt::in_range(file.GetLength() + offset)) + if(!mpt::in_range(file.GetLength() + offset)) { return -1; } - return file.Seek(mpt::saturate_cast(file.GetLength() + offset)) ? 0 : -1; + return file.Seek(mpt::saturate_cast(file.GetLength() + offset)) ? 0 : -1; default: return -1; @@ -714,7 +714,7 @@ static int VorbisfileFilereaderSeek(void *datasource, ogg_int64_t offset, int wh static long VorbisfileFilereaderTell(void *datasource) { FileReader &file = *mpt::void_ptr(datasource); - FileReader::off_t result = file.GetPosition(); + FileReader::pos_type result = file.GetPosition(); if(!mpt::in_range(result)) { return -1; @@ -1790,7 +1790,7 @@ bool CSoundFile::ReadMO3(FileReader &file, ModLoadingFlags loadFlags) cwtv = chunk.ReadUint16LE(); break; case MOD_TYPE_XM: - chunk.ReadString(madeWithTracker, mpt::Charset::CP437, std::min(FileReader::off_t(32), chunk.GetLength())); + chunk.ReadString(madeWithTracker, mpt::Charset::CP437, std::min(FileReader::pos_type(32), chunk.GetLength())); break; case MOD_TYPE_MTM: { diff --git a/soundlib/Load_mod.cpp b/soundlib/Load_mod.cpp index aa3162d38b0..4484a90e49e 100644 --- a/soundlib/Load_mod.cpp +++ b/soundlib/Load_mod.cpp @@ -1237,7 +1237,7 @@ bool CSoundFile::ReadMOD(FileReader &file, ModLoadingFlags loadFlags) // On the other hand, the loop points in Purple Motions's SOUL-O-M.MOD are completely broken and shouldn't be treated like this. // As it was most likely written in Scream Tracker, it has empty sample slots with a default volume of 64, which we use for // rejecting this quirk for that file. - FileReader::off_t nextSample = file.GetPosition() + sampleIO.CalculateEncodedSize(sample.nLength); + FileReader::pos_type nextSample = file.GetPosition() + sampleIO.CalculateEncodedSize(sample.nLength); if(isMdKd && onlyAmigaNotes && !hasEmptySampleWithVolume) sample.nLength = std::max(sample.nLength, sample.nLoopEnd); @@ -1611,7 +1611,7 @@ bool CSoundFile::ReadM15(FileReader &file, ModLoadingFlags loadFlags) // Setup channel pan positions and volume SetupMODPanning(); - FileReader::off_t patOffset = file.GetPosition(); + FileReader::pos_type patOffset = file.GetPosition(); // Scan patterns to identify Ultimate Soundtracker modules. uint32 illegalBytes = 0, totalNumDxx = 0; diff --git a/soundlib/Load_mt2.cpp b/soundlib/Load_mt2.cpp index 719561784b0..8f5bddbed26 100644 --- a/soundlib/Load_mt2.cpp +++ b/soundlib/Load_mt2.cpp @@ -438,7 +438,7 @@ bool CSoundFile::ReadMT2(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } diff --git a/soundlib/Load_mtm.cpp b/soundlib/Load_mtm.cpp index 55d408d17b7..1dbbb5500b6 100644 --- a/soundlib/Load_mtm.cpp +++ b/soundlib/Load_mtm.cpp @@ -126,7 +126,7 @@ bool CSoundFile::ReadMTM(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } diff --git a/soundlib/Load_mus_km.cpp b/soundlib/Load_mus_km.cpp index da67bb8696b..f6fb6cc563a 100644 --- a/soundlib/Load_mus_km.cpp +++ b/soundlib/Load_mus_km.cpp @@ -154,7 +154,7 @@ bool CSoundFile::ReadMUS_KM(FileReader &file, ModLoadingFlags loadFlags) return false; if(!ValidateHeader(fileHeader)) return false; - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) return false; if(loadFlags == onlyVerifyHeader) return true; diff --git a/soundlib/Load_plm.cpp b/soundlib/Load_plm.cpp index 34f401f392a..c0f2d3cbbc7 100644 --- a/soundlib/Load_plm.cpp +++ b/soundlib/Load_plm.cpp @@ -131,7 +131,7 @@ bool CSoundFile::ReadPLM(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } diff --git a/soundlib/Load_ptm.cpp b/soundlib/Load_ptm.cpp index 2c7c2ebbe98..5a65c700c79 100644 --- a/soundlib/Load_ptm.cpp +++ b/soundlib/Load_ptm.cpp @@ -157,7 +157,7 @@ bool CSoundFile::ReadPTM(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } diff --git a/soundlib/Load_s3m.cpp b/soundlib/Load_s3m.cpp index e9ea9ed9cb2..4f280ef47a6 100644 --- a/soundlib/Load_s3m.cpp +++ b/soundlib/Load_s3m.cpp @@ -219,7 +219,7 @@ bool CSoundFile::ReadS3M(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } diff --git a/soundlib/Load_stm.cpp b/soundlib/Load_stm.cpp index a338382b25f..e007c6a3350 100644 --- a/soundlib/Load_stm.cpp +++ b/soundlib/Load_stm.cpp @@ -224,7 +224,7 @@ bool CSoundFile::ReadSTM(FileReader &file, ModLoadingFlags loadFlags) return false; if(!fileHeader.Validate()) return false; - if(!file.CanRead(mpt::saturate_cast(fileHeader.GetHeaderMinimumAdditionalSize()))) + if(!file.CanRead(mpt::saturate_cast(fileHeader.GetHeaderMinimumAdditionalSize()))) return false; if(loadFlags == onlyVerifyHeader) return true; @@ -376,7 +376,7 @@ bool CSoundFile::ReadSTM(FileReader &file, ModLoadingFlags loadFlags) // ST2 just plays random noise for samples with a default volume of 0 if(sample.nLength && sample.nVolume > 0) { - FileReader::off_t sampleOffset = sampleOffsets[smp - 1] << 4; + FileReader::pos_type sampleOffset = sampleOffsets[smp - 1] << 4; // acidlamb.stm has some bogus samples with sample offsets past EOF if(sampleOffset > sizeof(STMFileHeader) && file.Seek(sampleOffset)) { @@ -455,7 +455,7 @@ bool CSoundFile::ReadSTX(FileReader &file, ModLoadingFlags loadFlags) return false; if(!fileHeader.Validate()) return false; - if (!file.CanRead(mpt::saturate_cast(fileHeader.GetHeaderMinimumAdditionalSize()))) + if (!file.CanRead(mpt::saturate_cast(fileHeader.GetHeaderMinimumAdditionalSize()))) return false; if(loadFlags == onlyVerifyHeader) return true; diff --git a/soundlib/Load_stp.cpp b/soundlib/Load_stp.cpp index c9ee2256996..e46251ffe42 100644 --- a/soundlib/Load_stp.cpp +++ b/soundlib/Load_stp.cpp @@ -365,7 +365,7 @@ bool CSoundFile::ReadSTP(FileReader &file, ModLoadingFlags loadFlags) if(fileHeader.version > 0) { // Scan for total number of channels - FileReader::off_t patOffset = file.GetPosition(); + FileReader::pos_type patOffset = file.GetPosition(); for(uint16 pat = 0; pat < numPatterns; pat++) { PATTERNINDEX actualPat = file.ReadUint16BE(); diff --git a/soundlib/Load_ult.cpp b/soundlib/Load_ult.cpp index 660121ae8a8..5aa2fe07efd 100644 --- a/soundlib/Load_ult.cpp +++ b/soundlib/Load_ult.cpp @@ -379,7 +379,7 @@ bool CSoundFile::ReadULT(FileReader &file, ModLoadingFlags loadFlags) { return true; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } diff --git a/soundlib/Load_xm.cpp b/soundlib/Load_xm.cpp index 3f730ed6f83..8a53afa705b 100644 --- a/soundlib/Load_xm.cpp +++ b/soundlib/Load_xm.cpp @@ -79,11 +79,11 @@ static int VorbisfileFilereaderSeek(void *datasource, ogg_int64_t offset, int wh { case SEEK_SET: { - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - return file.Seek(mpt::saturate_cast(offset)) ? 0 : -1; + return file.Seek(mpt::saturate_cast(offset)) ? 0 : -1; } break; case SEEK_CUR: @@ -94,32 +94,32 @@ static int VorbisfileFilereaderSeek(void *datasource, ogg_int64_t offset, int wh { return -1; } - if(!mpt::in_range(0-offset)) + if(!mpt::in_range(0-offset)) { return -1; } - return file.SkipBack(mpt::saturate_cast(0 - offset)) ? 0 : -1; + return file.SkipBack(mpt::saturate_cast(0 - offset)) ? 0 : -1; } else { - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - return file.Skip(mpt::saturate_cast(offset)) ? 0 : -1; + return file.Skip(mpt::saturate_cast(offset)) ? 0 : -1; } } break; case SEEK_END: { - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - if(!mpt::in_range(file.GetLength() + offset)) + if(!mpt::in_range(file.GetLength() + offset)) { return -1; } - return file.Seek(mpt::saturate_cast(file.GetLength() + offset)) ? 0 : -1; + return file.Seek(mpt::saturate_cast(file.GetLength() + offset)) ? 0 : -1; } break; default: @@ -130,7 +130,7 @@ static int VorbisfileFilereaderSeek(void *datasource, ogg_int64_t offset, int wh static long VorbisfileFilereaderTell(void *datasource) { FileReader &file = *mpt::void_ptr(datasource); - FileReader::off_t result = file.GetPosition(); + FileReader::pos_type result = file.GetPosition(); if(!mpt::in_range(result)) { return -1; @@ -243,7 +243,7 @@ static void ReadXMPatterns(FileReader &file, const XMFileHeader &fileHeader, CSo sndFile.Patterns.ResizeArray(fileHeader.patterns); for(PATTERNINDEX pat = 0; pat < fileHeader.patterns; pat++) { - FileReader::off_t curPos = file.GetPosition(); + FileReader::pos_type curPos = file.GetPosition(); uint32 headerSize = file.ReadUint32LE(); file.Skip(1); // Pack method (= 0) @@ -588,7 +588,7 @@ bool CSoundFile::ReadXM(FileReader &file, ModLoadingFlags loadFlags) { return false; } - if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) + if(!file.CanRead(mpt::saturate_cast(GetHeaderMinimumAdditionalSize(fileHeader)))) { return false; } else if(loadFlags == onlyVerifyHeader) @@ -922,7 +922,7 @@ bool CSoundFile::ReadXM(FileReader &file, ModLoadingFlags loadFlags) // Read mix plugins information if(file.CanRead(8)) { - FileReader::off_t oldPos = file.GetPosition(); + FileReader::pos_type oldPos = file.GetPosition(); LoadMixPlugins(file); if(file.GetPosition() != oldPos) { diff --git a/soundlib/Message.cpp b/soundlib/Message.cpp index a0f8e845692..7b0535682db 100644 --- a/soundlib/Message.cpp +++ b/soundlib/Message.cpp @@ -109,7 +109,7 @@ bool SongMessage::Read(const std::byte *data, size_t length, LineEnding lineEndi bool SongMessage::Read(FileReader &file, const size_t length, LineEnding lineEnding) { - FileReader::off_t readLength = std::min(static_cast(length), file.BytesLeft()); + FileReader::pos_type readLength = std::min(static_cast(length), file.BytesLeft()); FileReader::PinnedView fileView = file.ReadPinnedView(readLength); bool success = Read(fileView.data(), fileView.size(), lineEnding); return success; @@ -159,7 +159,7 @@ bool SongMessage::ReadFixedLineLength(const std::byte *data, const size_t length bool SongMessage::ReadFixedLineLength(FileReader &file, const size_t length, const size_t lineLength, const size_t lineEndingLength) { - FileReader::off_t readLength = std::min(static_cast(length), file.BytesLeft()); + FileReader::pos_type readLength = std::min(static_cast(length), file.BytesLeft()); FileReader::PinnedView fileView = file.ReadPinnedView(readLength); bool success = ReadFixedLineLength(fileView.data(), fileView.size(), lineLength, lineEndingLength); return success; diff --git a/soundlib/SampleFormatFLAC.cpp b/soundlib/SampleFormatFLAC.cpp index d7d2a3a96dd..5c16feeeace 100644 --- a/soundlib/SampleFormatFLAC.cpp +++ b/soundlib/SampleFormatFLAC.cpp @@ -79,7 +79,7 @@ struct FLACDecoder FileReader &file = static_cast(client_data)->m_file; if(*bytes > 0) { - FileReader::off_t readBytes = *bytes; + FileReader::pos_type readBytes = *bytes; LimitMax(readBytes, file.BytesLeft()); file.ReadRaw(mpt::byte_cast(mpt::span(buffer, readBytes))); *bytes = readBytes; @@ -96,7 +96,7 @@ struct FLACDecoder static FLAC__StreamDecoderSeekStatus seek_cb(const FLAC__StreamDecoder *, FLAC__uint64 absolute_byte_offset, void *client_data) { FileReader &file = static_cast(client_data)->m_file; - if(!file.Seek(static_cast(absolute_byte_offset))) + if(!file.Seek(static_cast(absolute_byte_offset))) return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; else return FLAC__STREAM_DECODER_SEEK_STATUS_OK; diff --git a/soundlib/SampleFormatMP3.cpp b/soundlib/SampleFormatMP3.cpp index e0cca5c37c4..72b79e53a48 100644 --- a/soundlib/SampleFormatMP3.cpp +++ b/soundlib/SampleFormatMP3.cpp @@ -109,25 +109,25 @@ class ComponentMPG123 FileReader &file = *static_cast(fp); if(whence == SEEK_CUR) { - if(!mpt::in_range(file.GetPosition() + offset)) + if(!mpt::in_range(file.GetPosition() + offset)) { return -1; } - file.Seek(static_cast(file.GetPosition() + offset)); + file.Seek(static_cast(file.GetPosition() + offset)); } else if(whence == SEEK_END) { - if(!mpt::in_range(file.GetLength() + offset)) + if(!mpt::in_range(file.GetLength() + offset)) { return -1; } - file.Seek(static_cast(file.GetLength() + offset)); + file.Seek(static_cast(file.GetLength() + offset)); } else { - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - file.Seek(static_cast(offset)); + file.Seek(static_cast(offset)); } return static_cast(file.GetPosition()); } @@ -142,7 +142,7 @@ class ComponentMPG123 static mpg123_off_t FileReaderLSeek(void *fp, mpg123_off_t offset, int whence) { FileReader &file = *static_cast(fp); - FileReader::off_t oldpos = file.GetPosition(); + FileReader::pos_type oldpos = file.GetPosition(); if(whence == SEEK_CUR) file.Seek(file.GetPosition() + offset); else if(whence == SEEK_END) file.Seek(file.GetLength() + offset); else file.Seek(offset); diff --git a/soundlib/SampleFormatOpus.cpp b/soundlib/SampleFormatOpus.cpp index 0d83410725c..45225de1ef9 100644 --- a/soundlib/SampleFormatOpus.cpp +++ b/soundlib/SampleFormatOpus.cpp @@ -58,11 +58,11 @@ static int OpusfileFilereaderSeek(void *stream, opus_int64 offset, int whence) { case SEEK_SET: { - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - return file.Seek(mpt::saturate_cast(offset)) ? 0 : -1; + return file.Seek(mpt::saturate_cast(offset)) ? 0 : -1; } break; case SEEK_CUR: @@ -73,32 +73,32 @@ static int OpusfileFilereaderSeek(void *stream, opus_int64 offset, int whence) { return -1; } - if(!mpt::in_range(0-offset)) + if(!mpt::in_range(0-offset)) { return -1; } - return file.SkipBack(mpt::saturate_cast(0 - offset)) ? 0 : -1; + return file.SkipBack(mpt::saturate_cast(0 - offset)) ? 0 : -1; } else { - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - return file.Skip(mpt::saturate_cast(offset)) ? 0 : -1; + return file.Skip(mpt::saturate_cast(offset)) ? 0 : -1; } } break; case SEEK_END: { - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - if(!mpt::in_range(file.GetLength() + offset)) + if(!mpt::in_range(file.GetLength() + offset)) { return -1; } - return file.Seek(mpt::saturate_cast(file.GetLength() + offset)) ? 0 : -1; + return file.Seek(mpt::saturate_cast(file.GetLength() + offset)) ? 0 : -1; } break; default: diff --git a/soundlib/SampleFormatVorbis.cpp b/soundlib/SampleFormatVorbis.cpp index 794715c6fcf..b4ec7a978fc 100644 --- a/soundlib/SampleFormatVorbis.cpp +++ b/soundlib/SampleFormatVorbis.cpp @@ -79,11 +79,11 @@ static int VorbisfileFilereaderSeek(void *datasource, ogg_int64_t offset, int wh { case SEEK_SET: { - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - return file.Seek(mpt::saturate_cast(offset)) ? 0 : -1; + return file.Seek(mpt::saturate_cast(offset)) ? 0 : -1; } break; case SEEK_CUR: @@ -94,32 +94,32 @@ static int VorbisfileFilereaderSeek(void *datasource, ogg_int64_t offset, int wh { return -1; } - if(!mpt::in_range(0-offset)) + if(!mpt::in_range(0-offset)) { return -1; } - return file.SkipBack(mpt::saturate_cast(0 - offset)) ? 0 : -1; + return file.SkipBack(mpt::saturate_cast(0 - offset)) ? 0 : -1; } else { - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - return file.Skip(mpt::saturate_cast(offset)) ? 0 : -1; + return file.Skip(mpt::saturate_cast(offset)) ? 0 : -1; } } break; case SEEK_END: { - if(!mpt::in_range(offset)) + if(!mpt::in_range(offset)) { return -1; } - if(!mpt::in_range(file.GetLength() + offset)) + if(!mpt::in_range(file.GetLength() + offset)) { return -1; } - return file.Seek(mpt::saturate_cast(file.GetLength() + offset)) ? 0 : -1; + return file.Seek(mpt::saturate_cast(file.GetLength() + offset)) ? 0 : -1; } break; default: diff --git a/soundlib/SampleFormats.cpp b/soundlib/SampleFormats.cpp index d9e8f2c30f3..05f21694302 100644 --- a/soundlib/SampleFormats.cpp +++ b/soundlib/SampleFormats.cpp @@ -610,7 +610,7 @@ struct Wave64Chunk { Wave64ChunkHeader header; - FileReader::off_t GetLength() const + FileReader::pos_type GetLength() const { uint64 length = header.Size; if(length < sizeof(Wave64ChunkHeader)) @@ -620,7 +620,7 @@ struct Wave64Chunk { length -= sizeof(Wave64ChunkHeader); } - return mpt::saturate_cast(length); + return mpt::saturate_cast(length); } mpt::UUID GetID() const @@ -1415,7 +1415,7 @@ bool CSoundFile::ReadXISample(SAMPLEINDEX nSample, FileReader &file) } uint16 numSamples = fileHeader.numSamples; - FileReader::off_t samplePos = sizeof(XIInstrumentHeader) + numSamples * sizeof(XMSample); + FileReader::pos_type samplePos = sizeof(XIInstrumentHeader) + numSamples * sizeof(XMSample); // Preferably read the middle-C sample auto sample = fileHeader.instrument.sampleMap[48]; if(sample >= fileHeader.numSamples) @@ -1488,7 +1488,7 @@ struct CAFChunk CAFChunkHeader header; - FileReader::off_t GetLength() const + FileReader::pos_type GetLength() const { int64 length = header.mChunkSize; if(length == -1) @@ -1499,7 +1499,7 @@ struct CAFChunk { length = std::numeric_limits::max(); // heuristic } - return mpt::saturate_cast(length); + return mpt::saturate_cast(length); } ChunkIdentifiers GetID() const @@ -1677,9 +1677,9 @@ bool CSoundFile::ReadCAFSample(SAMPLEINDEX nSample, FileReader &file, bool mayNo { uint32 stringID = stringsChunk.ReadUint32BE(); int64 offset = stringsChunk.ReadIntBE(); - if(offset >= 0 && mpt::in_range(offset)) + if(offset >= 0 && mpt::in_range(offset)) { - stringData.Seek(mpt::saturate_cast(offset)); + stringData.Seek(mpt::saturate_cast(offset)); std::string str; if(stringData.ReadNullString(str)) { @@ -2357,7 +2357,7 @@ bool CSoundFile::ReadITIInstrument(INSTRUMENTINDEX nInstr, FileReader &file) // In order to properly compute the position, in file, of eventual extended settings // such as "attack" we need to keep the "real" size of the last sample as those extra // setting will follow this sample in the file - FileReader::off_t extraOffset = file.GetPosition(); + FileReader::pos_type extraOffset = file.GetPosition(); // Reading Samples std::vector samplemap(nsamples, 0); @@ -2366,7 +2366,7 @@ bool CSoundFile::ReadITIInstrument(INSTRUMENTINDEX nInstr, FileReader &file) smp = GetNextFreeSample(nInstr, smp + 1); if(smp == SAMPLEINDEX_INVALID) break; samplemap[i] = smp; - const FileReader::off_t offset = file.GetPosition(); + const FileReader::pos_type offset = file.GetPosition(); if(!ReadITSSample(smp, file, false)) smp--; extraOffset = std::max(extraOffset, file.GetPosition()); diff --git a/soundlib/SampleIO.cpp b/soundlib/SampleIO.cpp index 472de34a538..b87fad9a3b7 100644 --- a/soundlib/SampleIO.cpp +++ b/soundlib/SampleIO.cpp @@ -41,12 +41,12 @@ size_t SampleIO::ReadSample(ModSample &sample, FileReader &file) const LimitMax(sample.nLength, MAX_SAMPLE_LENGTH); - FileReader::off_t bytesRead = 0; // Amount of memory that has been read from file + FileReader::pos_type bytesRead = 0; // Amount of memory that has been read from file - FileReader::off_t filePosition = file.GetPosition(); + FileReader::pos_type filePosition = file.GetPosition(); const std::byte * sourceBuf = nullptr; FileReader::PinnedView restrictedSampleDataView; - FileReader::off_t fileSize = 0; + FileReader::pos_type fileSize = 0; if(UsesFileReaderForDecoding()) { sourceBuf = nullptr; diff --git a/soundlib/UMXTools.cpp b/soundlib/UMXTools.cpp index b636f1d2265..df1c4dd3579 100644 --- a/soundlib/UMXTools.cpp +++ b/soundlib/UMXTools.cpp @@ -118,7 +118,7 @@ static bool FindNameTableEntryImpl(TFile &file, const FileHeader &fileHeader, co return false; } bool result = false; - const FileReader::off_t oldpos = file.GetPosition(); + const FileReader::pos_type oldpos = file.GetPosition(); if(file.Seek(fileHeader.nameOffset)) { for(uint32 i = 0; i < fileHeader.nameCount && file.CanRead(5); i++) diff --git a/soundlib/WAVTools.h b/soundlib/WAVTools.h index a0744647e4c..381f2f4c097 100644 --- a/soundlib/WAVTools.h +++ b/soundlib/WAVTools.h @@ -294,7 +294,7 @@ class WAVReader FileReader sampleData, smplChunk, instChunk, xtraChunk, wsmpChunk, cueChunk; FileReader::ChunkList infoChunk; - FileReader::off_t sampleLength; + FileReader::pos_type sampleLength; WAVFormatChunk formatInfo; uint16 subFormat; uint16 codePage; diff --git a/unarchiver/unzip.cpp b/unarchiver/unzip.cpp index bb1b1b8b014..9d6f2dad82d 100644 --- a/unarchiver/unzip.cpp +++ b/unarchiver/unzip.cpp @@ -79,11 +79,11 @@ struct ZipFileAbstraction default: return -1; } - if(!mpt::in_range(destination)) + if(!mpt::in_range(destination)) { return 1; } - return (file.Seek(static_cast(destination)) ? 0 : 1); + return (file.Seek(static_cast(destination)) ? 0 : 1); } static int ZCALLBACK fclose_mem(voidpf, voidpf)