opt: add extra check about the existence of metadata file

This commit is contained in:
YiFang Xiao 2023-05-21 16:28:15 +08:00 committed by xiaoyifang
parent f562b9bb5f
commit 5188ebd646

View file

@ -1,9 +1,14 @@
#include "metadata.hh"
#include "toml.hpp"
#include <QDebug>
#include <QFile>
std::optional< Metadata::result > Metadata::load( std::string_view filepath )
{
if ( !QFile::exists( QString::fromStdString( std::string{ filepath } ) ) ) {
return std::nullopt;
}
// by default, the optional will be initialized as std::nullopt
Metadata::result result{};
toml::table tbl;