summaryrefslogtreecommitdiff
path: root/wii/common.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-09-12 14:57:44 +0200
committerTreeki <treeki@gmail.com>2012-09-12 14:57:44 +0200
commit3189ca5efc5826405bf2e9c7d9949ad5ea9a8a10 (patch)
treed10e8cd4e462db28dd3c2f995905c4df57a20fed /wii/common.cpp
parentbe8b56a7f0a8f6ba5456a099b61d032fd8aa2f61 (diff)
downloadLayoutStudio-3189ca5efc5826405bf2e9c7d9949ad5ea9a8a10.tar.gz
LayoutStudio-3189ca5efc5826405bf2e9c7d9949ad5ea9a8a10.zip
initial un-exporter version
Diffstat (limited to 'wii/common.cpp')
-rw-r--r--wii/common.cpp23
1 files changed, 23 insertions, 0 deletions
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;
+}