Remove uses of QByteArray from Project

This commit is contained in:
Gary Talent 2017-05-20 02:26:32 -05:00
parent 3d8887c6ac
commit fc71e02fa4
2 changed files with 10 additions and 10 deletions

View File

@ -6,7 +6,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#include <QByteArray>
#include <QDir> #include <QDir>
#include "project.hpp" #include "project.hpp"
@ -31,23 +30,25 @@ Project::~Project() {
void Project::create() { void Project::create() {
QDir().mkpath(m_path); QDir().mkpath(m_path);
m_romBuff = QSharedPointer<QByteArray>(new QByteArray(1024, 0)); auto buffSize = 1024;
FileSystem32::format((uint8_t*) m_romBuff->data(), m_romBuff->size(), true); auto buff = new uint8_t[buffSize];
m_fs = createFileSystem((uint8_t*) m_romBuff->data(), m_romBuff->size()); FileSystem32::format(buff, buffSize, true);
m_fs = createFileSystem(buff, buffSize, true);
QFile file(m_path + ROM_FILE); QFile file(m_path + ROM_FILE);
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
file.write(*m_romBuff); file.write((const char*) buff);
file.close(); file.close();
} }
int Project::open() { int Project::open() {
QFile file(m_path + ROM_FILE); QFile file(m_path + ROM_FILE);
m_romBuff = QSharedPointer<QByteArray>(new QByteArray(file.size(), 0)); auto buffSize = file.size();
auto buff = new uint8_t[buffSize];
if (file.exists()) { if (file.exists()) {
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
if (file.read(m_romBuff->data(), file.size()) > 0) { if (file.read((char*) buff, buffSize) > 0) {
m_fs = createFileSystem((uint8_t*) m_romBuff->data(), m_romBuff->size()); m_fs = createFileSystem((uint8_t*) buff, buffSize, true);
return 0; return 0;
} else { } else {
return 1; return 1;
@ -60,7 +61,7 @@ int Project::open() {
void Project::save() { void Project::save() {
QFile file(m_path + ROM_FILE); QFile file(m_path + ROM_FILE);
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
file.write(*m_romBuff); file.write((const char*) m_fs->buff(), m_fs->size());
file.close(); file.close();
} }

View File

@ -22,7 +22,6 @@ class Project: public QObject {
static QString ROM_FILE; static QString ROM_FILE;
QString m_path = ""; QString m_path = "";
QSharedPointer<QByteArray> m_romBuff;
ox::FileSystem *m_fs = nullptr; ox::FileSystem *m_fs = nullptr;
public: public: