Commit b5f587dd2d6e1ae9115423784c3fe89a56a72e1b

Authored by Josh Klontz
1 parent 2e518145

QtUtils readFile/writeFile new defaults

sdk/core/core.cpp
... ... @@ -80,14 +80,14 @@ struct AlgorithmCore
80 80 out << Globals->classes;
81 81  
82 82 // Compress and save to file
83   - QtUtils::writeFile(model, data);
  83 + QtUtils::writeFile(model, data, -1);
84 84 }
85 85  
86 86 void load(const QString &model)
87 87 {
88 88 // Load from file and decompress
89 89 QByteArray data;
90   - QtUtils::readFile(model, data);
  90 + QtUtils::readFile(model, data, true);
91 91  
92 92 // Create stream
93 93 QDataStream in(&data, QFile::ReadOnly);
... ...
sdk/core/qtutils.cpp
... ... @@ -81,11 +81,12 @@ void QtUtils::readFile(const QString &amp;file, QStringList &amp;lines)
81 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 86 QFile f(file);
87 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 90 f.close();
90 91 }
91 92  
... ...
sdk/core/qtutils.h
... ... @@ -34,10 +34,10 @@ namespace QtUtils
34 34 QStringList getFiles(const QString &regexp);
35 35 QStringList readLines(const QString &file);
36 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 38 void writeFile(const QString &file, const QStringList &lines);
39 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 42 /**** Directory Utilities ****/
43 43 void touchDir(const QDir &dir);
... ...
sdk/plugins/meta.cpp
... ... @@ -394,7 +394,7 @@ private:
394 394 QDataStream stream(&byteArray, QFile::WriteOnly);
395 395 stream << description;
396 396 transform->store(stream);
397   - QtUtils::writeFile(baseName, byteArray);
  397 + QtUtils::writeFile(baseName, byteArray, -1);
398 398 }
399 399  
400 400 void project(const Template &src, Template &dst) const
... ... @@ -421,7 +421,7 @@ private:
421 421  
422 422 qDebug("Loading %s", qPrintable(baseName));
423 423 QByteArray data;
424   - QtUtils::readFile(file, data);
  424 + QtUtils::readFile(file, data, true);
425 425 QDataStream stream(&data, QFile::ReadOnly);
426 426 stream >> description;
427 427 transform = Transform::make(description);
... ...
1   -Subproject commit bcb22c79894d34b35891d4122e92e933380ec8ba
  1 +Subproject commit 504960df12db25e09c39ab098fb8614c1db51617
... ...