Moonlight-XboxOG latest
Moonlight Xbox OG is a port of the Moonlight Game Streaming client to the original Xbox console.
cover_art_cache.cpp File Reference

Implements cover art cache persistence. More...

#include "src/startup/cover_art_cache.h"
#include <cerrno>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include "src/platform/error_utils.h"
#include "src/platform/filesystem_utils.h"
#include "src/startup/storage_paths.h"
Include dependency graph for cover_art_cache.cpp:

Functions

std::string startup::build_cover_art_cache_key (std::string_view hostUuid, std::string_view hostAddress, int appId)
 Build a stable cache key for one host app's cover art.
 
bool startup::cover_art_exists (std::string_view cacheKey, const std::string &cacheRoot=default_cover_art_cache_root())
 Return whether cached cover art exists for a given key.
 
std::string startup::default_cover_art_cache_root ()
 Return the default root directory for cached cover art.
 
bool startup::delete_cover_art (std::string_view cacheKey, std::string *errorMessage=nullptr, const std::string &cacheRoot=default_cover_art_cache_root())
 Delete cached cover art for a given key.
 
LoadCoverArtResult startup::load_cover_art (std::string_view cacheKey, const std::string &cacheRoot=default_cover_art_cache_root())
 Load cached cover art bytes for a given key.
 
SaveCoverArtResult startup::save_cover_art (std::string_view cacheKey, const std::vector< unsigned char > &bytes, const std::string &cacheRoot=default_cover_art_cache_root())
 Save cover art bytes for a given cache key.
 

Detailed Description

Implements cover art cache persistence.

Function Documentation

◆ build_cover_art_cache_key()

std::string startup::build_cover_art_cache_key ( std::string_view hostUuid,
std::string_view hostAddress,
int appId )

Build a stable cache key for one host app's cover art.

Parameters
hostUuidHost UUID when available.
hostAddressHost address used as a fallback discriminator.
appIdHost application identifier.
Returns
Stable cache key suitable for file-system storage.

◆ cover_art_exists()

bool startup::cover_art_exists ( std::string_view cacheKey,
const std::string & cacheRoot = default_cover_art_cache_root() )

Return whether cached cover art exists for a given key.

Parameters
cacheKeyStable cover-art cache key.
cacheRootCache root directory to inspect.
Returns
true when cached art exists on disk.

◆ default_cover_art_cache_root()

std::string startup::default_cover_art_cache_root ( )

Return the default root directory for cached cover art.

Returns
Default cover-art cache root path.

◆ delete_cover_art()

bool startup::delete_cover_art ( std::string_view cacheKey,
std::string * errorMessage = nullptr,
const std::string & cacheRoot = default_cover_art_cache_root() )

Delete cached cover art for a given key.

Parameters
cacheKeyStable cover-art cache key.
errorMessageOptional output for deletion failures.
cacheRootCache root directory containing the artifact.
Returns
true when the artifact was deleted or was already absent.

◆ load_cover_art()

LoadCoverArtResult startup::load_cover_art ( std::string_view cacheKey,
const std::string & cacheRoot = default_cover_art_cache_root() )

Load cached cover art bytes for a given key.

Parameters
cacheKeyStable cover-art cache key.
cacheRootCache root directory containing the artifact.
Returns
Loaded cover-art bytes plus file-existence and error details.

◆ save_cover_art()

SaveCoverArtResult startup::save_cover_art ( std::string_view cacheKey,
const std::vector< unsigned char > & bytes,
const std::string & cacheRoot = default_cover_art_cache_root() )

Save cover art bytes for a given cache key.

Parameters
cacheKeyStable cover-art cache key.
bytesCover art bytes to persist.
cacheRootCache root directory where the artifact should be written.
Returns
Save result including success state and error detail.