Commit b5f587dd2d6e1ae9115423784c3fe89a56a72e1b
1 parent
2e518145
QtUtils readFile/writeFile new defaults
Showing
5 changed files
with
10 additions
and
9 deletions
sdk/core/core.cpp
| @@ -80,14 +80,14 @@ struct AlgorithmCore | @@ -80,14 +80,14 @@ struct AlgorithmCore | ||
| 80 | out << Globals->classes; | 80 | out << Globals->classes; |
| 81 | 81 | ||
| 82 | // Compress and save to file | 82 | // Compress and save to file |
| 83 | - QtUtils::writeFile(model, data); | 83 | + QtUtils::writeFile(model, data, -1); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | void load(const QString &model) | 86 | void load(const QString &model) |
| 87 | { | 87 | { |
| 88 | // Load from file and decompress | 88 | // Load from file and decompress |
| 89 | QByteArray data; | 89 | QByteArray data; |
| 90 | - QtUtils::readFile(model, data); | 90 | + QtUtils::readFile(model, data, true); |
| 91 | 91 | ||
| 92 | // Create stream | 92 | // Create stream |
| 93 | QDataStream in(&data, QFile::ReadOnly); | 93 | QDataStream in(&data, QFile::ReadOnly); |
sdk/core/qtutils.cpp
| @@ -81,11 +81,12 @@ void QtUtils::readFile(const QString &file, QStringList &lines) | @@ -81,11 +81,12 @@ void QtUtils::readFile(const QString &file, QStringList &lines) | ||
| 81 | f.close(); | 81 | f.close(); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | -void QtUtils::readFile(const QString &file, QByteArray &data) | 84 | +void QtUtils::readFile(const QString &file, QByteArray &data, bool uncompress) |
| 85 | { | 85 | { |
| 86 | QFile f(file); | 86 | QFile f(file); |
| 87 | if (!f.open(QFile::ReadOnly)) qFatal("QtUtils::readFile unable to open %s for reading.", qPrintable(file)); | 87 | if (!f.open(QFile::ReadOnly)) qFatal("QtUtils::readFile unable to open %s for reading.", qPrintable(file)); |
| 88 | - data = qUncompress(f.readAll()); | 88 | + data = f.readAll(); |
| 89 | + if (uncompress) data = qUncompress(data); | ||
| 89 | f.close(); | 90 | f.close(); |
| 90 | } | 91 | } |
| 91 | 92 |
sdk/core/qtutils.h
| @@ -34,10 +34,10 @@ namespace QtUtils | @@ -34,10 +34,10 @@ namespace QtUtils | ||
| 34 | QStringList getFiles(const QString ®exp); | 34 | QStringList getFiles(const QString ®exp); |
| 35 | QStringList readLines(const QString &file); | 35 | QStringList readLines(const QString &file); |
| 36 | void readFile(const QString &file, QStringList &lines); | 36 | void readFile(const QString &file, QStringList &lines); |
| 37 | - void readFile(const QString &file, QByteArray &data); | 37 | + void readFile(const QString &file, QByteArray &data, bool uncompress = false); |
| 38 | void writeFile(const QString &file, const QStringList &lines); | 38 | void writeFile(const QString &file, const QStringList &lines); |
| 39 | void writeFile(const QString &file, const QString &data); | 39 | void writeFile(const QString &file, const QString &data); |
| 40 | - void writeFile(const QString &file, const QByteArray &data, int compression = -1); | 40 | + void writeFile(const QString &file, const QByteArray &data, int compression = 0); |
| 41 | 41 | ||
| 42 | /**** Directory Utilities ****/ | 42 | /**** Directory Utilities ****/ |
| 43 | void touchDir(const QDir &dir); | 43 | void touchDir(const QDir &dir); |
sdk/plugins/meta.cpp
| @@ -394,7 +394,7 @@ private: | @@ -394,7 +394,7 @@ private: | ||
| 394 | QDataStream stream(&byteArray, QFile::WriteOnly); | 394 | QDataStream stream(&byteArray, QFile::WriteOnly); |
| 395 | stream << description; | 395 | stream << description; |
| 396 | transform->store(stream); | 396 | transform->store(stream); |
| 397 | - QtUtils::writeFile(baseName, byteArray); | 397 | + QtUtils::writeFile(baseName, byteArray, -1); |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | void project(const Template &src, Template &dst) const | 400 | void project(const Template &src, Template &dst) const |
| @@ -421,7 +421,7 @@ private: | @@ -421,7 +421,7 @@ private: | ||
| 421 | 421 | ||
| 422 | qDebug("Loading %s", qPrintable(baseName)); | 422 | qDebug("Loading %s", qPrintable(baseName)); |
| 423 | QByteArray data; | 423 | QByteArray data; |
| 424 | - QtUtils::readFile(file, data); | 424 | + QtUtils::readFile(file, data, true); |
| 425 | QDataStream stream(&data, QFile::ReadOnly); | 425 | QDataStream stream(&data, QFile::ReadOnly); |
| 426 | stream >> description; | 426 | stream >> description; |
| 427 | transform = Transform::make(description); | 427 | transform = Transform::make(description); |