seek.c 601 B

12345678910111213141516171819202122232425262728293031
  1. #include <grass/config.h>
  2. #include <stdio.h>
  3. #include <sys/types.h>
  4. #include <grass/gis.h>
  5. #include <grass/glocale.h>
  6. off_t G_ftell(FILE *fp)
  7. {
  8. #ifdef HAVE_LARGEFILES
  9. return ftello(fp);
  10. #else
  11. return (off_t) ftell(fp);
  12. #endif
  13. }
  14. void G_fseek(FILE *fp, off_t offset, int whence)
  15. {
  16. #ifdef HAVE_LARGEFILES
  17. if (fseeko(fp, offset, whence) != 0)
  18. G_fatal_error(_("unable to seek"));
  19. #else
  20. long loff = (long) offset;
  21. if ((off_t) loff != offset)
  22. G_fatal_error(_("seek offset out of range"));
  23. if (fseek(fp, loff, whence) != 0)
  24. G_fatal_error(_("unable to seek"));
  25. #endif
  26. }