UserData::Save() returns success status.

This commit is contained in:
Bartosz Taudul
2026-06-05 17:40:22 +02:00
parent e95a757e6c
commit 4564a626b2
2 changed files with 11 additions and 9 deletions

View File

@@ -106,9 +106,9 @@ void UserData::StoreSourceSubstitutions( const std::vector<SourceRegex>& data )
m_sourceSubstitutions = data;
}
void UserData::Save()
bool UserData::Save()
{
if( !m_preserveState ) return;
if( !m_preserveState ) return false;
assert( Valid() );
nlohmann::json json = {
@@ -169,12 +169,14 @@ void UserData::Save()
}
auto f = OpenFile( true );
if( f )
{
auto str = json.dump( 2 );
fwrite( str.c_str(), 1, str.size(), f );
fclose( f );
}
if( !f ) return false;
auto str = json.dump( 2 );
const auto sz = str.size();
const auto wrote = fwrite( str.c_str(), 1, sz, f );
fclose( f );
return sz == wrote;
}
template<typename T>

View File

@@ -39,7 +39,7 @@ public:
void LoadSourceSubstitutions( std::vector<SourceRegex>& data );
void StoreSourceSubstitutions( const std::vector<SourceRegex>& data );
void Save();
bool Save();
private:
FILE* OpenFile( bool write );