mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
opt: add extra check about the existence of metadata file
This commit is contained in:
parent
f562b9bb5f
commit
5188ebd646
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue