ProjectFormat.h header
#include <ew/app/persistence/ProjectFormat.h>
Namespace ew::app::persistence
Functions
ew::core::foundation::Result< QString > ew::app::persistence::createProjectWorkingCopy(const QString &path)
Copies the project at path to a sibling working copy and returns the new path.
The escape hatch from projectIsFromNewerBuild. Refusing a too-new project keeps it intact, but on its own it leaves the writer holding a file they cannot open at all – so this makes a SEPARATE copy they can work in, and leaves the original untouched under its own name to be merged back by a build that understands it.
The copy is named <stem>-WorkingCopy<suffix> beside the original, and never overwrites: an existing working copy takes a numbered sibling instead. That is the whole safety property. A second attempt silently replacing the first would destroy work done in it, which is the exact data loss this feature exists to avoid, arriving through the door marked "recovery".
Works for a bundle (a file copy) and a folder project (a recursive copy), routed on isProjectBundlePath.
QString ew::app::persistence::currentProjectFormatVersion()
The version stamp this build writes into every project it saves.
It is the application's own version (ew::core::foundation::versionString), not a separate format number, because the question a reader of the stamp actually asks is "was this written by a build newer than mine?" – and the app version is the only thing that answers it without a second numbering scheme to keep in step.
bool ew::app::persistence::projectIsFromNewerBuild(const QString &stampedVersion)
Whether stampedVersion was written by a build strictly newer than this one.
This is the data-loss guard, and the loss is silent. The store reads the keys it knows and rebuilds the file from the object on save, so a project written by a newer build and saved by an older one does not warn, does not corrupt, and does not refuse – every field the older build does not know is simply gone from the file afterwards. Nothing else in the pipeline notices.
An empty or unparseable stamp is never "newer": an absent stamp means an older project (see readProjectFormatVersion), and refusing a project because its stamp is malformed would turn a corrupted byte into a lockout.
QString ew::app::persistence::readProjectFormatVersion(const QString &path)
The version stamped in the project at path, or an empty string when it carries none.
path is either a project folder or a single-file bundle; it routes on isProjectBundlePath the way every other "a project path" seam does. A bundle is read through bundleTextSnapshot rather than extracted, so asking the question costs nothing and leaves no temporary folder behind – which matters because the caller asks BEFORE deciding whether to open at all.
Empty means the project predates 0.3.0, which is when the stamp was introduced. That is NOT an error: an unstamped project opens normally and gets its stamp on the next save. The stamp exists to catch the dangerous direction – a NEWER build's project opened by an older one – and an old project is never in that direction.