Donner 0.8.0-pre
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
DocumentSave.h File Reference
#include <cstddef>
#include <filesystem>
#include <iosfwd>
#include <string>
#include <string_view>
Include dependency graph for DocumentSave.h:

Classes

struct  donner::editor::DocumentSaveResult
 Detailed outcome from a document save attempt. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Enumerations

enum class  donner::editor::DocumentSaveStatus {
  Ok ,
  OpenFailed ,
  WriteFailed ,
  CloseFailed
}
 Result category for saving an SVG source file. More...

Functions

std::ostream & donner::editor::operator<< (std::ostream &os, DocumentSaveStatus status)
 Human-readable stream output for DocumentSaveStatus.
DocumentSaveResult donner::editor::SaveSourceToPath (const std::filesystem::path &path, std::string_view source)
 Write SVG source bytes to path without following symlinks.

Enumeration Type Documentation

◆ DocumentSaveStatus

Result category for saving an SVG source file.

Enumerator
Ok 

The source was written successfully.

OpenFailed 

The destination could not be opened.

WriteFailed 

The full source could not be written.

CloseFailed 

Closing the file descriptor failed after writing.

Function Documentation

◆ SaveSourceToPath()

DocumentSaveResult donner::editor::SaveSourceToPath ( const std::filesystem::path & path,
std::string_view source )
nodiscard

Write SVG source bytes to path without following symlinks.

Existing destinations are opened with O_NOFOLLOW; missing destinations are created with O_CREAT | O_EXCL. The function intentionally does not pre-stat the path, avoiding a TOCTOU window between inspection and open.

Parameters
pathDestination file path.
sourceSVG source bytes to persist.
Returns
Save status, including errno and a diagnostic message on failure.