database: Check if files exist before opening

This prevents an error message (and possible corruption) by continuing
with the open() function even if the file doesn't exist.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-01-22 19:31:31 -05:00 committed by Anna Schumaker
parent 36b76dcfc3
commit e94063473e
2 changed files with 3 additions and 1 deletions

View File

@ -45,6 +45,9 @@ void Database<T> :: load()
{
unsigned int db_size;
if (file.exists() == false)
return;
try {
file.open(OPEN_READ);
} catch (int error) {

View File

@ -300026,7 +300026,6 @@ db[99999] = 100000
ERROR: A file with hint = FILE_TYPE_INVALID cannot be opened
Test 3
ERROR: A file with hint = FILE_TYPE_INVALID cannot be opened
Test 4
Database size: 5