Skip to content

Commit 3ee3579

Browse files
committed
Fixed the example failing to find the example files in the new directory structure
+ Fixed a GCC unused variable warning in example1
1 parent 0179277 commit 3ee3579

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

examples/example1/main.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@
2020
#include "../../src/Transaction.h"
2121

2222

23+
static const char* filename_example_db3 = "examples/example1/example.db3";
24+
static const char* filename_logo_png = "examples/example1/logo.png";
25+
26+
2327
/// Object Oriented Basic example
2428
class Example
2529
{
2630
public:
2731
// Constructor
2832
Example(void) :
29-
mDb("example.db3"), // Open a database file in readonly mode
33+
mDb(filename_example_db3), // Open a database file in readonly mode
3034
mQuery(mDb, "SELECT * FROM test WHERE weight > :min_weight")// Compile a SQL query, containing one parameter (index 1)
3135
{
3236
}
@@ -64,7 +68,7 @@ int main (void)
6468
try
6569
{
6670
// Open a database file in readonly mode
67-
SQLite::Database db("example.db3"); // SQLITE_OPEN_READONLY
71+
SQLite::Database db(filename_example_db3); // SQLITE_OPEN_READONLY
6872
std::cout << "SQLite database file '" << db.getFilename().c_str() << "' opened successfully\n";
6973

7074
// Test if the 'test' table exists
@@ -136,7 +140,7 @@ int main (void)
136140
try
137141
{
138142
// Open a database file in readonly mode
139-
SQLite::Database db("example.db3"); // SQLITE_OPEN_READONLY
143+
SQLite::Database db(filename_example_db3); // SQLITE_OPEN_READONLY
140144
std::cout << "SQLite database file '" << db.getFilename().c_str() << "' opened successfully\n";
141145

142146
// WARNING: Be very careful with this dangerous method: you have to
@@ -271,7 +275,7 @@ int main (void)
271275
db.exec("DROP TABLE IF EXISTS test");
272276
db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, value BLOB)");
273277

274-
FILE* fp = fopen("logo.png", "rb");
278+
FILE* fp = fopen(filename_logo_png, "rb");
275279
if (NULL != fp)
276280
{
277281
char buffer[16*1024];
@@ -293,7 +297,7 @@ int main (void)
293297
}
294298
else
295299
{
296-
std::cout << "file logo.png not found !\n";
300+
std::cout << "file " << filename_logo_png << " not found !\n";
297301
abort(); // unexpected error : abort the example program
298302
}
299303

@@ -312,6 +316,7 @@ int main (void)
312316
size = colBlob.getBytes ();
313317
std::cout << "row : (" << query.getColumn(0) << ", size=" << size << ")\n";
314318
size_t sizew = fwrite(blob, 1, size, fp);
319+
assert(sizew == size);
315320
fclose (fp);
316321
}
317322
}

0 commit comments

Comments
 (0)