Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- //Try to connect using FDO. If you can open/close without exceptions, it's a valid SDF3 file
- } catch (OSGeo.FDO.Common.Exception ex) {
- if (ex.Message == "SDF file appears to be version 2.1 or older. Please convert to SDF version 3") {
- //Try using SDF loader. If you can open/close without errors, it's a valid SDFv2 file
- }
- }
- //while we have the file open, check if it is
- //an older SDF (2.1 or older) by reading the first few bytes.
- //all this is done in little-endian.
- unsigned long value;
- fread(&value, sizeof(unsigned long), 1, f);
- fclose(f);
- if((value & 0x0000ffff) == 0x00002c00)
- {
- // 2.x versions
- // Might also include 1.0, but it is not
- //guaranteed to be old SDF since other binary files
- //can have the same initial bytes
- //Note that for SDF3 (SQLite) files, the first 4 DWORDS are:
- //value[0] == 0x00000000
- //value[1] == 0x00000001
- //value[2] == 0x00000000
- //value[3] == 0x00053162
- //But the correct way to check version from now on is to
- //open the Schema database and read the version number, which
- //we do later in this function.
- throw ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement