wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ExternalFilePath Namespace Reference

Functions

std::optional< QString > forReading (const QString &storedValue, const QString &contextDir, SerializationPurpose purpose)
QString forWriting (const QString &path, SerializationPurpose purpose)
QString resolve (const QString &storedPath, const QString &contextDir)

Function Documentation

◆ forReading()

std::optional< QString > ExternalFilePath::forReading ( const QString & storedValue,
const QString & contextDir,
SerializationPurpose purpose )
inline

Returns the value that should replace an element's current external-file field when restoring storedValue, or std::nullopt to mean "leave the current value untouched". For SerializationPurpose::InMemorySnapshot, always returns storedValue verbatim (lossless round-trip, no cross-version staleness is possible). For SerializationPurpose::PortableFile, a resource-path storedValue returns std::nullopt (a stale saved resource identifier from an older app version must not clobber the element's current compiled-in default); anything else is resolved against contextDir via resolve() above.

Definition at line 68 of file ExternalFilePath.h.

References InMemorySnapshot, and resolve().

Referenced by AudioBox::load().

◆ forWriting()

QString ExternalFilePath::forWriting ( const QString & path,
SerializationPurpose purpose )
inline

Returns how path should be written for purpose. A resource path (":/...") is never touched. Otherwise: SerializationPurpose::PortableFile strips it to its bare filename (the file is expected to live alongside the saved file – see WorkSpace::save()'s copy step); SerializationPurpose::InMemorySnapshot writes it verbatim, losslessly.

Definition at line 52 of file ExternalFilePath.h.

References InMemorySnapshot.

Referenced by AudioBox::save(), GraphicElementSerializer::save(), and IC::save().

◆ resolve()

QString ExternalFilePath::resolve ( const QString & storedPath,
const QString & contextDir )
inline

Resolves a stored non-resource path against contextDir for loading: tries the path as given (joined with contextDir if relative) first; if that doesn't name a plain file, falls back to a bare-filename lookup in the same directory (handles a foreign-OS or stale absolute path saved on a different machine/app version, e.g. a Windows "C:\...\file.ext" opened on Linux). Returns storedPath unchanged if it's empty or contextDir is empty – nothing to resolve. Purpose-independent: pure path arithmetic, safe to call regardless of SerializationPurpose.

Definition at line 32 of file ExternalFilePath.h.

Referenced by forReading(), and ICLoader::loadFile().