From 3189ca5efc5826405bf2e9c7d9949ad5ea9a8a10 Mon Sep 17 00:00:00 2001 From: Treeki Date: Wed, 12 Sep 2012 14:57:44 +0200 Subject: initial un-exporter version --- wii/common.cpp | 23 +++++++++++++++++++++++ wii/common.h | 2 ++ 2 files changed, 25 insertions(+) (limited to 'wii') diff --git a/wii/common.cpp b/wii/common.cpp index 8f552b3..4ea59a0 100644 --- a/wii/common.cpp +++ b/wii/common.cpp @@ -131,4 +131,27 @@ void WriteFixedLengthASCII(QDataStream &out, const QString str, int length) { out.writeRawData(paddedStr.constData(), paddedStr.length()); } +QString ReadVariableLengthASCII(QDataStream &in) { + qint64 savedPos = in.device()->pos(); + int stringLength = 0; + char check; + + in >> (quint8&)check; + while (check != 0) { + stringLength += 1; + in >> (quint8&)check; + } + + // now read the string + char *buffer = new char[stringLength]; + + in.device()->seek(savedPos); + in.readRawData(buffer, stringLength); + + QString output = QString::fromAscii(buffer, stringLength); + + delete[] buffer; + + return output; +} diff --git a/wii/common.h b/wii/common.h index b440841..792ae27 100644 --- a/wii/common.h +++ b/wii/common.h @@ -108,4 +108,6 @@ void WriteStringList(QDataStream &out, QStringList list); QString ReadFixedLengthASCII(QDataStream &in, int length); void WriteFixedLengthASCII(QDataStream &out, QString str, int length); +QString ReadVariableLengthASCII(QDataStream &in); + #endif // WIICOMMON_H -- cgit v1.2.3