@@ -216,7 +216,7 @@ void Database::loadExtension(const char* apExtensionName, const char *apEntryPoi
216
216
(void )apExtensionName;
217
217
(void )apEntryPointName;
218
218
219
- throw std::runtime_error (" sqlite extensions are disabled" );
219
+ throw SQLite::Exception (" sqlite extensions are disabled" );
220
220
#else
221
221
#ifdef SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION // Since SQLite 3.13 (2016-05-18):
222
222
// Security warning:
@@ -248,8 +248,7 @@ void Database::key(const std::string& aKey) const
248
248
#else // SQLITE_HAS_CODEC
249
249
if (passLen > 0 )
250
250
{
251
- const SQLite::Exception exception (" No encryption support, recompile with SQLITE_HAS_CODEC to enable." );
252
- throw exception ;
251
+ throw SQLite::Exception (" No encryption support, recompile with SQLITE_HAS_CODEC to enable." );
253
252
}
254
253
#endif // SQLITE_HAS_CODEC
255
254
}
@@ -271,33 +270,32 @@ void Database::rekey(const std::string& aNewKey) const
271
270
}
272
271
#else // SQLITE_HAS_CODEC
273
272
static_cast <void >(aNewKey); // silence unused parameter warning
274
- const SQLite::Exception exception (" No encryption support, recompile with SQLITE_HAS_CODEC to enable." );
275
- throw exception ;
273
+ throw SQLite::Exception (" No encryption support, recompile with SQLITE_HAS_CODEC to enable." );
276
274
#endif // SQLITE_HAS_CODEC
277
275
}
278
276
279
277
// Test if a file contains an unencrypted database.
280
278
bool Database::isUnencrypted (const std::string& aFilename)
281
279
{
282
- if (aFilename.length () > 0 )
280
+ if (aFilename.empty () )
283
281
{
284
- std::ifstream fileBuffer (aFilename. c_str (), std::ios::in | std::ios::binary );
285
- char header[ 16 ];
286
- if (fileBuffer. is_open ())
287
- {
288
- fileBuffer. seekg ( 0 , std::ios::beg) ;
289
- fileBuffer.getline (header, 16 );
290
- fileBuffer. close ();
291
- }
292
- else
293
- {
294
- const SQLite::Exception exception ( " Error opening file: " + aFilename);
295
- throw exception ;
296
- }
297
- return strncmp (header, " SQLite format 3 \000 " , 16 ) == 0 ;
282
+ throw SQLite::Exception ( " Could not open database, the aFilename parameter was empty. " );
283
+ }
284
+
285
+ std::ifstream fileBuffer (aFilename. c_str (), std::ios::in | std::ios::binary);
286
+ char header[ 16 ] ;
287
+ if ( fileBuffer.is_open ())
288
+ {
289
+ fileBuffer. seekg ( 0 , std::ios::beg);
290
+ fileBuffer. getline (header, 16 );
291
+ fileBuffer. close ();
292
+ }
293
+ else
294
+ {
295
+ throw SQLite::Exception ( " Error opening file: " + aFilename) ;
298
296
}
299
- const SQLite::Exception exception ( " Could not open database, the aFilename parameter was empty. " );
300
- throw exception ;
297
+
298
+ return strncmp (header, " SQLite format 3 \000 " , 16 ) == 0 ;
301
299
}
302
300
303
301
// This is a reference implementation of live backup taken from the official sit:
0 commit comments