diff --git a/src/nostalgia/studio/lib/project.cpp b/src/nostalgia/studio/lib/project.cpp index 734c20d8..367debd5 100644 --- a/src/nostalgia/studio/lib/project.cpp +++ b/src/nostalgia/studio/lib/project.cpp @@ -66,12 +66,14 @@ void Project::lsProcDir(QStringList *paths, QString path) const { const auto fullPath = path + "/" + name.c_str(); oxRequireT(stat, m_fs->stat(fullPath.toUtf8().data())); switch (stat.fileType) { - case ox::FileType_NormalFile: + case ox::FileType::NormalFile: paths->push_back(fullPath); break; - case ox::FileType_Directory: + case ox::FileType::Directory: lsProcDir(paths, fullPath); break; + case ox::FileType::None: + break; } } } diff --git a/src/nostalgia/studio/oxfstreeview.cpp b/src/nostalgia/studio/oxfstreeview.cpp index d9557ed6..9f0ddf0b 100644 --- a/src/nostalgia/studio/oxfstreeview.cpp +++ b/src/nostalgia/studio/oxfstreeview.cpp @@ -16,13 +16,13 @@ namespace nostalgia::studio { -OxFSFile::OxFSFile(ox::FileSystem *fs, QString path, OxFSFile *parentItem) { +OxFSFile::OxFSFile(ox::FileSystem *fs, const QString &path, OxFSFile *parentItem) { m_path = path; m_parentItem = parentItem; // find children oxRequireT(stat, fs->stat(static_cast(m_path.toUtf8()))); QVector ls; - if (stat.fileType == ox::FileType_Directory) { + if (stat.fileType == ox::FileType::Directory) { oxRequireT(names, fs->ls(m_path.toUtf8())); for (const auto &name : names) { if (name[0] != '.') { @@ -33,14 +33,14 @@ OxFSFile::OxFSFile(ox::FileSystem *fs, QString path, OxFSFile *parentItem) { } auto p = m_path; // make sure ends with path separator - if (fs->stat(p.toUtf8().data()).value.fileType == ox::FileType_Directory && + if (fs->stat(p.toUtf8().data()).value.fileType == ox::FileType::Directory && p.size() && p.back() != QDir::separator()) { p += QDir::separator(); } for (const auto &name : ls) { if (name != "." && name != "..") { - const auto path = m_path.size() ? m_path + '/' + name : name; - const auto ch = new OxFSFile(fs, path, this); + const auto filePath = m_path.size() ? m_path + '/' + name : name; + const auto ch = new OxFSFile(fs, filePath, this); m_childItems.push_back(ch); } } @@ -54,7 +54,7 @@ void OxFSFile::appendChild(OxFSModel *model, QStringList pathItems, QString curr if (!pathItems.empty()) { const auto &target = pathItems[0]; currentPath += "/" + target; - int index = m_childItems.size(); + int index = static_cast(m_childItems.size()); for (int i = 0; i < m_childItems.size(); i++) { if (m_childItems[i]->name() >= target) { index = i; @@ -82,7 +82,7 @@ OxFSFile *OxFSFile::child(int row) { } int OxFSFile::childCount() const { - return m_childItems.size(); + return static_cast(m_childItems.size()); } int OxFSFile::columnCount() const { @@ -95,7 +95,7 @@ QVariant OxFSFile::data(int) const { int OxFSFile::row() const { if (m_parentItem) { - return m_parentItem->m_childItems.indexOf(const_cast(this)); + return static_cast(m_parentItem->m_childItems.indexOf(const_cast(this))); } else { return 0; } @@ -209,7 +209,7 @@ int OxFSModel::columnCount(const QModelIndex &parent) const { } } -void OxFSModel::updateFile(QString path) { +void OxFSModel::updateFile(const QString &path) { auto pathItems = path.split("/").mid(1); m_rootItem->appendChild(this, pathItems, ""); } diff --git a/src/nostalgia/studio/oxfstreeview.hpp b/src/nostalgia/studio/oxfstreeview.hpp index 68a4c98e..a7c238bd 100644 --- a/src/nostalgia/studio/oxfstreeview.hpp +++ b/src/nostalgia/studio/oxfstreeview.hpp @@ -23,7 +23,7 @@ class OxFSFile { QVector m_childItems; public: - OxFSFile(ox::FileSystem *fs, QString path, OxFSFile *parentItem = nullptr); + OxFSFile(ox::FileSystem *fs, const QString &path, OxFSFile *parentItem = nullptr); ~OxFSFile(); @@ -31,19 +31,25 @@ class OxFSFile { OxFSFile *child(int row); - [[nodiscard]] int childCount() const; + [[nodiscard]] + int childCount() const; - [[nodiscard]] int columnCount() const; + [[nodiscard]] + int columnCount() const; - [[nodiscard]] QVariant data(int column) const; + [[nodiscard]] + QVariant data(int column) const; - [[nodiscard]] int row() const; + [[nodiscard]] + int row() const; OxFSFile *parentItem(); - [[nodiscard]] QString name() const; + [[nodiscard]] + QString name() const; - [[nodiscard]] QString path() const; + [[nodiscard]] + QString path() const; }; class OxFSModel: public QAbstractItemModel { @@ -75,7 +81,7 @@ class OxFSModel: public QAbstractItemModel { [[nodiscard]] int columnCount(const QModelIndex &parent) const override; public slots: - void updateFile(QString path); + void updateFile(const QString &path); }; diff --git a/src/nostalgia/tools/pack/pack.cpp b/src/nostalgia/tools/pack/pack.cpp index 898273c5..4a882267 100644 --- a/src/nostalgia/tools/pack/pack.cpp +++ b/src/nostalgia/tools/pack/pack.cpp @@ -40,7 +40,7 @@ static ox::Error transformClaw(ox::FileSystem *dest, const ox::String &path) noe for (const auto &name : fileList) { const auto filePath = path + name; oxRequire(stat, dest->stat(filePath.c_str())); - if (stat.fileType == ox::FileType_Directory) { + if (stat.fileType == ox::FileType::Directory) { const auto dir = path + name + '/'; oxReturnError(transformClaw(dest, dir)); } else { @@ -83,7 +83,7 @@ static ox::Error copy(ox::FileSystem *src, ox::FileSystem *dest, const ox::Strin } oxOutf("reading {}\n", name); oxRequire(stat, src->stat(currentFile.c_str())); - if (stat.fileType == ox::FileType_Directory) { + if (stat.fileType == ox::FileType::Directory) { oxReturnError(dest->mkdir(currentFile.c_str(), true)); oxReturnError(copy(src, dest, currentFile + '/')); } else {