Best way check if a file is a SQLite DB?
- Try to open it and see if it fails.
- Look at the first bytes to see if it's "SQLite format 3", as described here: https://www.sqlite.org/fileformat2.html
I was going to do #2, but maybe older files, or future files, could be different. ??
The first one would open an empty file successfully, which is probably not what you want.
Note that using sqlite3_open() doesn't do anything with the file at all. It just sets up a structure in memory. SQLite only looks at the file on storage when you try to do the first thing that needs to know what's in it.
I'd go with your other answer: check the file header to see whether it matches the file-structure documentation.
The SQLite 3 database header is stable; it will not change for any major version 3 of the library.