This won't break the ABI compatibility.
writeBlock(ByteVector::fromUInt(d->objects.size(), false));
writeBlock(ByteVector("\x01\x02", 2));
- insert(data, 30, static_cast<ulong>(d->headerSize - 30));
+ insert(data, 30, static_cast<unsigned long>(d->headerSize - 30));
d->headerSize = data.size() + 30;
StringList lines = d->tag.comment().split("\n");
for(unsigned short i = 0; i < instrumentCount; ++ i) {
seek(192L + length + ((long)i << 2));
- ulong instrumentOffset = 0;
+ unsigned long instrumentOffset = 0;
if(!readU32L(instrumentOffset))
return false;
for(unsigned short i = 0; i < sampleCount; ++ i) {
seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2));
- ulong sampleOffset = 0;
+ unsigned long sampleOffset = 0;
if(!readU32L(sampleOffset))
return false;
unsigned short special = 0;
unsigned short messageLength = 0;
- ulong messageOffset = 0;
+ unsigned long messageOffset = 0;
seek(46);
if(!readU16L(special))
return false;
- ulong fileSize = File::length();
+ unsigned long fileSize = File::length();
if(special & Properties::MessageAttached) {
seek(54);
if(!readU16L(messageLength) || !readU32L(messageOffset))
{
}
-void Mod::FileBase::writeString(const String &s, ulong size, char padding)
+void Mod::FileBase::writeString(const String &s, unsigned long size, char padding)
{
ByteVector data(s.data(String::Latin1));
data.resize(size, padding);
writeBlock(data);
}
-bool Mod::FileBase::readString(String &s, ulong size)
+bool Mod::FileBase::readString(String &s, unsigned long size)
{
ByteVector data(readBlock(size));
if(data.size() < size) return false;
writeBlock(ByteVector::fromShort(number, false));
}
-void Mod::FileBase::writeU32L(ulong number)
+void Mod::FileBase::writeU32L(unsigned long number)
{
writeBlock(ByteVector::fromUInt(number, false));
}
writeBlock(ByteVector::fromShort(number, true));
}
-void Mod::FileBase::writeU32B(ulong number)
+void Mod::FileBase::writeU32B(unsigned long number)
{
writeBlock(ByteVector::fromUInt(number, true));
}
return true;
}
-bool Mod::FileBase::readU32L(ulong &number) {
+bool Mod::FileBase::readU32L(unsigned long &number) {
ByteVector data(readBlock(4));
if(data.size() < 4) return false;
number = data.toUInt(false);
return true;
}
-bool Mod::FileBase::readU32B(ulong &number) {
+bool Mod::FileBase::readU32B(unsigned long &number) {
ByteVector data(readBlock(4));
if(data.size() < 4) return false;
number = data.toUInt(true);
FileBase(FileName file);
FileBase(IOStream *stream);
- void writeString(const String &s, ulong size, char padding = 0);
+ void writeString(const String &s, unsigned long size, char padding = 0);
void writeByte(unsigned char byte);
void writeU16L(unsigned short number);
- void writeU32L(ulong number);
+ void writeU32L(unsigned long number);
void writeU16B(unsigned short number);
- void writeU32B(ulong number);
+ void writeU32B(unsigned long number);
- bool readString(String &s, ulong size);
+ bool readString(String &s, unsigned long size);
bool readByte(unsigned char &byte);
bool readU16L(unsigned short &number);
- bool readU32L(ulong &number);
+ bool readU32L(unsigned long &number);
bool readU16B(unsigned short &number);
- bool readU32B(ulong &number);
+ bool readU32B(unsigned long &number);
};
}
#define READ_BYTE(setter) READ(setter,unsigned char,readByte)
#define READ_U16L(setter) READ(setter,unsigned short,readU16L)
-#define READ_U32L(setter) READ(setter,ulong,readU32L)
+#define READ_U32L(setter) READ(setter,unsigned long,readU32L)
#define READ_U16B(setter) READ(setter,unsigned short,readU16B)
-#define READ_U32B(setter) READ(setter,ulong,readU32B)
+#define READ_U32B(setter) READ(setter,unsigned long,readU32B)
#define READ_STRING(setter,size) \
{ \
#define READ_BYTE_AS(name) READ_AS(unsigned char,name,readByte)
#define READ_U16L_AS(name) READ_AS(unsigned short,name,readU16L)
-#define READ_U32L_AS(name) READ_AS(ulong,name,readU32L)
+#define READ_U32L_AS(name) READ_AS(unsigned long,name,readU32L)
#define READ_U16B_AS(name) READ_AS(unsigned short,name,readU16B)
-#define READ_U32B_AS(name) READ_AS(ulong,name,readU32B)
+#define READ_U32B_AS(name) READ_AS(unsigned long,name,readU32B)
#define READ_STRING_AS(name,size) \
String name; \
break;
}
- const ulong begSilence = readSize(data, pos);
+ const unsigned long begSilence = readSize(data, pos);
if(pos > dataSize - 2) {
debug("MPC::Properties::readSV8() - \"SH\" packet is corrupt.");
break;
ByteVector buffer;
while (position > 0) {
- long size = ulong(position) < bufferSize() ? position : bufferSize();
+ long size = std::min<long>(position, bufferSize());
position -= size;
seek(position);
// Xing header found.
- if(data.size() < static_cast<ulong>(offset + 16)) {
+ if(data.size() < static_cast<unsigned long>(offset + 16)) {
debug("MPEG::XingHeader::parse() -- Xing header found but too short.");
return;
}
// VBRI header found.
- if(data.size() < static_cast<ulong>(offset + 32)) {
+ if(data.size() < static_cast<unsigned long>(offset + 32)) {
debug("MPEG::XingHeader::parse() -- VBRI header found but too short.");
return;
}
// Couldn't find an existing chunk, so let's create a new one.
uint i = d->chunks.size() - 1;
- ulong offset = d->chunks[i].offset + d->chunks[i].size;
+ unsigned long offset = d->chunks[i].offset + d->chunks[i].size;
// First we update the global size
}
void RIFF::File::writeChunk(const ByteVector &name, const ByteVector &data,
- ulong offset, ulong replace, uint leadingPadding)
+ unsigned long offset, unsigned long replace, uint leadingPadding)
{
ByteVector combined;
if(leadingPadding) {
void read();
void writeChunk(const ByteVector &name, const ByteVector &data,
- ulong offset, ulong replace = 0,
+ unsigned long offset, unsigned long replace = 0,
uint leadingPadding = 0);
class FilePrivate;
return FileName(""); // XXX do we need a name?
}
-ByteVector ByteVectorStream::readBlock(ulong length)
+ByteVector ByteVectorStream::readBlock(unsigned long length)
{
if(length == 0)
return ByteVector();
d->position += size;
}
-void ByteVectorStream::insert(const ByteVector &data, ulong start, ulong replace)
+void ByteVectorStream::insert(const ByteVector &data, unsigned long start, unsigned long replace)
{
long sizeDiff = data.size() - replace;
if(sizeDiff < 0) {
}
else if(sizeDiff > 0) {
truncate(length() + sizeDiff);
- ulong readPosition = start + replace;
- ulong writePosition = start + data.size();
+ unsigned long readPosition = start + replace;
+ unsigned long writePosition = start + data.size();
memmove(d->data.data() + writePosition, d->data.data() + readPosition, length() - sizeDiff - readPosition);
}
seek(start);
writeBlock(data);
}
-void ByteVectorStream::removeBlock(ulong start, ulong length)
+void ByteVectorStream::removeBlock(unsigned long start, unsigned long length)
{
- ulong readPosition = start + length;
- ulong writePosition = start;
- if(readPosition < ulong(ByteVectorStream::length())) {
- ulong bytesToMove = ByteVectorStream::length() - readPosition;
+ unsigned long readPosition = start + length;
+ unsigned long writePosition = start;
+ if(readPosition < static_cast<unsigned long>(ByteVectorStream::length())) {
+ unsigned long bytesToMove = ByteVectorStream::length() - readPosition;
memmove(d->data.data() + writePosition, d->data.data() + readPosition, bytesToMove);
writePosition += bytesToMove;
}
/*!
* Reads a block of size \a length at the current get pointer.
*/
- ByteVector readBlock(ulong length);
+ ByteVector readBlock(unsigned long length);
/*!
* Attempts to write the block \a data at the current get pointer. If the
* \note This method is slow since it requires rewriting all of the file
* after the insertion point.
*/
- void insert(const ByteVector &data, ulong start = 0, ulong replace = 0);
+ void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
/*!
* Removes a block of the file starting a \a start and continuing for
* \note This method is slow since it involves rewriting all of the file
* after the removed portion.
*/
- void removeBlock(ulong start = 0, ulong length = 0);
+ void removeBlock(unsigned long start = 0, unsigned long length = 0);
/*!
* Returns true if the file is read only (or if the file can not be opened).
return tag()->setProperties(properties);
}
-ByteVector File::readBlock(ulong length)
+ByteVector File::readBlock(unsigned long length)
{
return d->stream->readBlock(length);
}
return -1;
}
-void File::insert(const ByteVector &data, ulong start, ulong replace)
+void File::insert(const ByteVector &data, unsigned long start, unsigned long replace)
{
d->stream->insert(data, start, replace);
}
-void File::removeBlock(ulong start, ulong length)
+void File::removeBlock(unsigned long start, unsigned long length)
{
d->stream->removeBlock(start, length);
}
/*!
* Reads a block of size \a length at the current get pointer.
*/
- ByteVector readBlock(ulong length);
+ ByteVector readBlock(unsigned long length);
/*!
* Attempts to write the block \a data at the current get pointer. If the
* \note This method is slow since it requires rewriting all of the file
* after the insertion point.
*/
- void insert(const ByteVector &data, ulong start = 0, ulong replace = 0);
+ void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
/*!
* Removes a block of the file starting a \a start and continuing for
* \note This method is slow since it involves rewriting all of the file
* after the removed portion.
*/
- void removeBlock(ulong start = 0, ulong length = 0);
+ void removeBlock(unsigned long start = 0, unsigned long length = 0);
/*!
* Returns true if the file is read only (or if the file can not be opened).
return d->name;
}
-ByteVector FileStream::readBlock(ulong length)
+ByteVector FileStream::readBlock(unsigned long length)
{
if(!isOpen()) {
debug("FileStream::readBlock() -- invalid file.");
if(length == 0)
return ByteVector();
- const ulong streamLength = static_cast<ulong>(FileStream::length());
+ const unsigned long streamLength = static_cast<unsigned long>(FileStream::length());
if(length > bufferSize() && length > streamLength)
length = streamLength;
writeFile(d->file, data);
}
-void FileStream::insert(const ByteVector &data, ulong start, ulong replace)
+void FileStream::insert(const ByteVector &data, unsigned long start, unsigned long replace)
{
if(!isOpen()) {
debug("FileStream::insert() -- invalid file.");
// the *differnce* in the tag sizes. We want to avoid overwriting parts
// that aren't yet in memory, so this is necessary.
- ulong bufferLength = bufferSize();
+ unsigned long bufferLength = bufferSize();
while(data.size() - replace > bufferLength)
bufferLength += bufferSize();
}
}
-void FileStream::removeBlock(ulong start, ulong length)
+void FileStream::removeBlock(unsigned long start, unsigned long length)
{
if(!isOpen()) {
debug("FileStream::removeBlock() -- invalid file.");
return;
}
- ulong bufferLength = bufferSize();
+ unsigned long bufferLength = bufferSize();
long readPosition = start + length;
long writePosition = start;
/*!
* Reads a block of size \a length at the current get pointer.
*/
- ByteVector readBlock(ulong length);
+ ByteVector readBlock(unsigned long length);
/*!
* Attempts to write the block \a data at the current get pointer. If the
* \note This method is slow since it requires rewriting all of the file
* after the insertion point.
*/
- void insert(const ByteVector &data, ulong start = 0, ulong replace = 0);
+ void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
/*!
* Removes a block of the file starting a \a start and continuing for
* \note This method is slow since it involves rewriting all of the file
* after the removed portion.
*/
- void removeBlock(ulong start = 0, ulong length = 0);
+ void removeBlock(unsigned long start = 0, unsigned long length = 0);
/*!
* Returns true if the file is read only (or if the file can not be opened).
/*!
* Reads a block of size \a length at the current get pointer.
*/
- virtual ByteVector readBlock(ulong length) = 0;
+ virtual ByteVector readBlock(unsigned long length) = 0;
/*!
* Attempts to write the block \a data at the current get pointer. If the
* \note This method is slow since it requires rewriting all of the file
* after the insertion point.
*/
- virtual void insert(const ByteVector &data, ulong start = 0, ulong replace = 0) = 0;
+ virtual void insert(const ByteVector &data,
+ unsigned long start = 0, unsigned long replace = 0) = 0;
/*!
* Removes a block of the file starting a \a start and continuing for
* \note This method is slow since it involves rewriting all of the file
* after the removed portion.
*/
- virtual void removeBlock(ulong start = 0, ulong length = 0) = 0;
+ virtual void removeBlock(unsigned long start = 0, unsigned long length = 0) = 0;
/*!
* Returns true if the file is read only (or if the file can not be opened).
using namespace TagLib;
using namespace XM;
using TagLib::uint;
-using TagLib::ulong;
/*!
* The Reader classes are helpers to make handling of the stripped XM
}
};
-class U32Reader : public NumberReader<ulong>
+class U32Reader : public NumberReader<unsigned long>
{
public:
- U32Reader(ulong &value, bool bigEndian = true) :
- NumberReader<ulong>(value, bigEndian)
+ U32Reader(unsigned long &value, bool bigEndian = true) :
+ NumberReader<unsigned long>(value, bigEndian)
{
}
* Read a unsigned 32 Bit integer into \a number. The byte order
* is controlled by \a bigEndian.
*/
- StructReader &u32(ulong &number, bool bigEndian)
+ StructReader &u32(unsigned long &number, bool bigEndian)
{
m_readers.append(new U32Reader(number, bigEndian));
return *this;
/*!
* Read a unsigned 32 Bit little endian integer into \a number.
*/
- StructReader &u32L(ulong &number)
+ StructReader &u32L(unsigned long &number)
{
return u32(number, false);
}
/*!
* Read a unsigned 32 Bit big endian integer into \a number.
*/
- StructReader &u32B(ulong &number)
+ StructReader &u32B(unsigned long &number)
{
return u32(number, true);
}
writeString(d->tag.trackerName(), 20);
seek(60);
- ulong headerSize = 0;
+ unsigned long headerSize = 0;
if(!readU32L(headerSize))
return false;
// need to read patterns again in order to seek to the instruments:
for(unsigned short i = 0; i < patternCount; ++ i) {
seek(pos);
- ulong patternHeaderLength = 0;
+ unsigned long patternHeaderLength = 0;
if(!readU32L(patternHeaderLength) || patternHeaderLength < 4)
return false;
uint sampleNameIndex = instrumentCount;
for(unsigned short i = 0; i < instrumentCount; ++ i) {
seek(pos);
- ulong instrumentHeaderSize = 0;
+ unsigned long instrumentHeaderSize = 0;
if(!readU32L(instrumentHeaderSize) || instrumentHeaderSize < 4)
return false;
return false;
}
- ulong sampleHeaderSize = 0;
+ unsigned long sampleHeaderSize = 0;
if(sampleCount > 0) {
seek(pos + 29);
if(instrumentHeaderSize < 33U || !readU32L(sampleHeaderSize))
for(unsigned short j = 0; j < sampleCount; ++ j) {
if(sampleHeaderSize > 4U) {
seek(pos);
- ulong sampleLength = 0;
+ unsigned long sampleLength = 0;
if(!readU32L(sampleLength))
return false;
.u16L(bpmSpeed);
uint count = header.read(*this, headerSize - 4U);
- uint size = std::min(headerSize - 4U, (ulong)header.size());
+ uint size = std::min(headerSize - 4U, (unsigned long)header.size());
READ_ASSERT(count == size);
pattern.byte(packingType).u16L(rowCount).u16L(dataSize);
uint count = pattern.read(*this, patternHeaderLength - 4U);
- READ_ASSERT(count == std::min(patternHeaderLength - 4U, (ulong)pattern.size()));
+ READ_ASSERT(count == std::min(patternHeaderLength - 4U, (unsigned long)pattern.size()));
seek(patternHeaderLength - (4 + count) + dataSize, Current);
}
// 4 for instrumentHeaderSize
uint count = 4 + instrument.read(*this, instrumentHeaderSize - 4U);
- READ_ASSERT(count == std::min(instrumentHeaderSize, (ulong)instrument.size() + 4));
+ READ_ASSERT(count == std::min(instrumentHeaderSize, (unsigned long)instrument.size() + 4));
- ulong sampleHeaderSize = 0;
+ unsigned long sampleHeaderSize = 0;
long offset = 0;
if(sampleCount > 0) {
sumSampleCount += sampleCount;
seek(instrumentHeaderSize - count - 4, Current);
for(unsigned short j = 0; j < sampleCount; ++ j) {
- ulong sampleLength = 0;
- ulong loopStart = 0;
- ulong loopLength = 0;
+ unsigned long sampleLength = 0;
+ unsigned long loopStart = 0;
+ unsigned long loopLength = 0;
unsigned char volume = 0;
unsigned char finetune = 0;
unsigned char sampleType = 0;
.string(sampleName, 22);
uint count = sample.read(*this, sampleHeaderSize);
- READ_ASSERT(count == std::min(sampleHeaderSize, (ulong)sample.size()));
+ READ_ASSERT(count == std::min(sampleHeaderSize, (unsigned long)sample.size()));
// skip unhandeled header proportion:
seek(sampleHeaderSize - count, Current);