I'm using GTK+ and SQLite as a front end for a small database program, and I cannot get SQLite to properly detect file type on open. Not matter what is opened, it returns SQLITE_OK.
I tried sqlite3_open
and sqlite3_open_v2
, the problem still persists. The output is always the same, regardless of what filetype is opened:
/home/shawn/Programming/languagedb/lang.db
0 6304656
good
/home/shawn/Programming/languagedb/Makefile
0 6304656
good
And here is the related code:
void OpenDialog()
{
GtkWidget *WinOpen;
WinOpen = gtk_file_chooser_dialog_new("Open Database",GTK_WINDOW(WinOpen),GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL);
if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(WinOpen)))
{
char *filename;
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(WinOpen));
printf("%s\n",filename);
db = NULL;
rc = sqlite3_open_v2(filename,&db,SQLITE_OPEN_READONLY,NULL);
printf("%i %i\n",rc,&db);
if(SQLITE_OK == rc && NULL != db)
{
printf("good\n");
}
sqlite3_close(db);
}
gtk_widget_destroy(WinOpen);
}