Tag: tocttou

如何检测sqlite3是否创建了数据库文件?

我正在编写一个程序,它使用sqlite3数据库文件来存储其数据。 如果我打开一个数据库文件 sqlite3_open_v2(filename, &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL) 如果数据库文件不存在,则创建该数据库文件。 如何在打开数据库文件之前查明数据库文件是否存在? sqlite3 shell使用如下代码: /* 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 from being created if a user mistypes the database name argument ** to the sqlite […]