tocttou

How do I detect if sqlite3 created a database file?

邮差的信 提交于 2019-12-10 17:54:24
问题 I'm writing a program that uses a sqlite3 database file to store its data. If I open a database file with sqlite3_open_v2(filename, &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL) the database file is created if it does not exist. How can I find out if the database file existed prior to opening it? The sqlite3 shell uses code like this: /* Go ahead and open the database file if it already exists. If the ** file does not exist, delay opening it. This prevents empty database ** files