Reputation: 1396
I have an SQLite Format 3 Database File with alot of garbage bytes appended to the end. It wont load in my SQLite Database Browser with the garbage there.
I've just read the spec for this file type. Here: http://www.sqlite.org/fileformat.html
I've tried multiplying the page size by number of pages but as I expected that did not give me the result I was looking for, even when I tried calculating the size for a Database of known file length.
Is there a way to Calculate the actual Database's File Size From the File Header, or any other method?
Upvotes: 0
Views: 2302
Reputation: 180020
When the database file is valid, the value at offset 28 specifies the size in pages.
When the database file is corrupt, the file contents cannot be trusted. If the header is still valid, the file size value probably shows the size that the file had before it became corrupted.
Please note that just appending garbage will not make a database file unreadable; it's likely that actual data in your file is lost.
Upvotes: 1