[olympic/studio] Fix NewMenu not to overwrite existing files or create a file without name
All checks were successful
Build / build (push) Successful in 2m30s
All checks were successful
Build / build (push) Successful in 2m30s
This commit is contained in:
@ -15,16 +15,21 @@ namespace studio {
|
||||
|
||||
class ItemMaker {
|
||||
public:
|
||||
ox::String const name;
|
||||
ox::String const typeName;
|
||||
ox::String const parentDir;
|
||||
ox::String const fileExt;
|
||||
constexpr explicit ItemMaker(ox::StringView pName, ox::StringView pParentDir, ox::CRStringView pFileExt) noexcept:
|
||||
name(pName),
|
||||
typeName(pName),
|
||||
parentDir(pParentDir),
|
||||
fileExt(pFileExt) {
|
||||
}
|
||||
virtual ~ItemMaker() noexcept = default;
|
||||
|
||||
[[nodiscard]]
|
||||
inline virtual ox::String itemPath(ox::StringView pName) const noexcept {
|
||||
return ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns path of the file created.
|
||||
* @param ctx
|
||||
@ -69,8 +74,8 @@ class ItemMakerT: public ItemMaker {
|
||||
m_fmt(pFmt) {
|
||||
}
|
||||
ox::Result<ox::String> write(turbine::Context &ctx, ox::CRStringView pName) const noexcept override {
|
||||
auto const path = ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt);
|
||||
auto sctx = turbine::applicationData<studio::StudioContext>(ctx);
|
||||
auto const path = itemPath(pName);
|
||||
auto const sctx = turbine::applicationData<studio::StudioContext>(ctx);
|
||||
keel::createUuidMapping(keelCtx(ctx), path, ox::UUID::generate().unwrap());
|
||||
oxReturnError(sctx->project->writeObj(path, m_item, m_fmt));
|
||||
return path;
|
||||
|
Reference in New Issue
Block a user