[keel,studio] Add ability to rename files
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#include <ox/claw/write.hpp>
|
||||
#include <ox/event/signal.hpp>
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/mc/mc.hpp>
|
||||
#include <ox/model/descwrite.hpp>
|
||||
#include <ox/std/hashmap.hpp>
|
||||
|
||||
@@ -26,6 +25,7 @@ enum class ProjectEvent {
|
||||
FileRecognized,
|
||||
FileDeleted,
|
||||
FileUpdated,
|
||||
FileMoved,
|
||||
};
|
||||
|
||||
[[nodiscard]]
|
||||
@@ -49,7 +49,7 @@ constexpr ox::StringView parentDir(ox::StringView path) noexcept {
|
||||
class Project: public ox::SignalHandler {
|
||||
private:
|
||||
ox::SmallMap<ox::String, ox::Optional<ox::ClawFormat>> m_typeFmt;
|
||||
keel::Context &m_ctx;
|
||||
keel::Context &m_kctx;
|
||||
ox::String m_path;
|
||||
ox::String m_projectDataDir;
|
||||
ox::String m_typeDescPath;
|
||||
@@ -92,6 +92,8 @@ class Project: public ox::SignalHandler {
|
||||
|
||||
ox::Result<ox::FileStat> stat(ox::StringViewCR path) const noexcept;
|
||||
|
||||
ox::Error moveItem(ox::StringViewCR src, ox::StringViewCR dest) noexcept;
|
||||
|
||||
ox::Error deleteItem(ox::StringViewCR path) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
@@ -114,7 +116,7 @@ class Project: public ox::SignalHandler {
|
||||
|
||||
ox::Result<ox::Buffer> loadBuff(ox::StringViewCR path) const noexcept;
|
||||
|
||||
ox::Error lsProcDir(ox::Vector<ox::String> *paths, ox::StringViewCR path) const noexcept;
|
||||
ox::Error lsProcDir(ox::Vector<ox::String> &paths, ox::StringViewCR path) const noexcept;
|
||||
|
||||
ox::Result<ox::Vector<ox::String>> listFiles(ox::StringViewCR path = "") const noexcept;
|
||||
|
||||
@@ -128,7 +130,8 @@ class Project: public ox::SignalHandler {
|
||||
// file.
|
||||
ox::Signal<ox::Error(ox::StringViewCR)> fileRecognized;
|
||||
ox::Signal<ox::Error(ox::StringViewCR)> fileDeleted;
|
||||
ox::Signal<ox::Error(ox::StringView, ox::UUID)> fileUpdated;
|
||||
ox::Signal<ox::Error(ox::StringViewCR path, ox::UUID const&id)> fileUpdated;
|
||||
ox::Signal<ox::Error(ox::StringViewCR newPath, ox::UUID const&id)> fileMoved;
|
||||
|
||||
};
|
||||
|
||||
@@ -151,8 +154,8 @@ ox::Error Project::writeObj(ox::StringViewCR path, T const&obj, ox::ClawFormat f
|
||||
if (!descExists) {
|
||||
OX_RETURN_ERROR(writeTypeStore());
|
||||
}
|
||||
OX_RETURN_ERROR(keel::reloadAsset(m_ctx, path));
|
||||
OX_REQUIRE(uuid, pathToUuid(m_ctx, path));
|
||||
OX_RETURN_ERROR(keel::reloadAsset(m_kctx, path));
|
||||
OX_REQUIRE(uuid, pathToUuid(m_kctx, path));
|
||||
fileUpdated.emit(path, uuid);
|
||||
return {};
|
||||
}
|
||||
@@ -200,6 +203,9 @@ ox::Error Project::subscribe(ProjectEvent e, ox::SignalHandler *tgt, Functor &&s
|
||||
case ProjectEvent::FileUpdated:
|
||||
connect(this, &Project::fileUpdated, tgt, slot);
|
||||
break;
|
||||
case ProjectEvent::FileMoved:
|
||||
connect(this, &Project::fileMoved, tgt, slot);
|
||||
break;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
Reference in New Issue
Block a user