Add missing nostalgia directory level in src tree

This commit is contained in:
2017-05-12 17:55:18 -05:00
parent 1b9f8f40f4
commit bfc87b50b1
43 changed files with 22 additions and 19 deletions
+75
View File
@@ -0,0 +1,75 @@
/*
* Copyright 2016-2017 gtalent2@gmail.com
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <QByteArray>
#include <QDir>
#include <project.hpp>
namespace nostalgia {
namespace studio {
using namespace ox;
QString Project::ROM_FILE = "/ROM.oxfs";
Project::Project(QString path) {
m_path = path;
}
Project::~Project() {
if (m_fs) {
delete m_fs;
}
}
void Project::create() {
QDir().mkpath(m_path);
m_romBuff = QSharedPointer<QByteArray>(new QByteArray(1024, 0));
FileSystem32::format(m_romBuff->data(), m_romBuff->size(), true);
m_fs = createFileSystem(m_romBuff->data(), m_romBuff->size());
m_fs->mkdir("/Tilesets");
QFile file(m_path + ROM_FILE);
file.open(QIODevice::WriteOnly);
file.write(*m_romBuff);
file.close();
}
int Project::open() {
QFile file(m_path + ROM_FILE);
m_romBuff = QSharedPointer<QByteArray>(new QByteArray(file.size(), 0));
if (file.exists()) {
file.open(QIODevice::ReadOnly);
if (file.read(m_romBuff->data(), file.size()) > 0) {
m_fs = createFileSystem(m_romBuff->data(), m_romBuff->size());
m_fs->mkdir("/Tilesets");
return 0;
} else {
return 1;
}
} else {
return 2;
}
}
void Project::save() {
QFile file(m_path + ROM_FILE);
file.open(QIODevice::WriteOnly);
file.write(*m_romBuff);
file.close();
}
FileSystem *Project::romFS() {
return m_fs;
}
}
}