Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. try {
  2. //Try to connect using FDO. If you can open/close without exceptions, it's a valid SDF3 file
  3. } catch (OSGeo.FDO.Common.Exception ex) {
  4. if (ex.Message == "SDF file appears to be version 2.1 or older. Please convert to SDF version 3") {
  5. //Try using SDF loader. If you can open/close without errors, it's a valid SDFv2 file
  6. }
  7. }
  8.  
  9. //while we have the file open, check if it is
  10. //an older SDF (2.1 or older) by reading the first few bytes.
  11. //all this is done in little-endian.
  12. unsigned long value;
  13. fread(&value, sizeof(unsigned long), 1, f);
  14. fclose(f);
  15.  
  16. if((value & 0x0000ffff) == 0x00002c00)
  17. {
  18. // 2.x versions
  19. // Might also include 1.0, but it is not
  20. //guaranteed to be old SDF since other binary files
  21. //can have the same initial bytes
  22.  
  23. //Note that for SDF3 (SQLite) files, the first 4 DWORDS are:
  24. //value[0] == 0x00000000
  25. //value[1] == 0x00000001
  26. //value[2] == 0x00000000
  27. //value[3] == 0x00053162
  28. //But the correct way to check version from now on is to
  29. //open the Schema database and read the version number, which
  30. //we do later in this function.
  31.  
  32. throw ...
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement