Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.2 KiB

  1. /***
  2. *fgetpos.c - Contains the fgetpos runtime
  3. *
  4. * Copyright (c) 1987-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Get file position (in an internal format).
  8. *
  9. *Revision History:
  10. * 01-16-87 JCR Module created.
  11. * 12-11-87 JCR Added "_LOAD_DS" to declaration
  12. * 02-15-90 GJF Fixed copyright and indents
  13. * 03-16-90 GJF Replaced _LOAD_DS with _CALLTYPE1 and added #include
  14. * <cruntime.h>.
  15. * 10-02-90 GJF New-style function declarator.
  16. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  17. * 12-23-94 GJF Use 64-bit file position (_ftelli64) for non-_MAC_.
  18. * 01-05-94 GJF Temporarily commented out above change due to MFC/IDE
  19. * bugs.
  20. * 01-24-95 GJF Restored 64-bit fpos_t support.
  21. * 06-28-96 SKS Enable 64-bit fpos_t support for the MAC
  22. * 05-17-99 PML Remove all Macintosh support.
  23. *
  24. *******************************************************************************/
  25. #include <cruntime.h>
  26. #include <stdio.h>
  27. #include <internal.h>
  28. /***
  29. *int fgetpos(stream,pos) - Get file position (internal format)
  30. *
  31. *Purpose:
  32. * Fgetpos gets the current file position for the file identified by
  33. * [stream]. The file position is returned in the object pointed to
  34. * by [pos] and is in internal format; that is, the user is not supposed
  35. * to interpret the value but simply use it in the fsetpos call. Our
  36. * implementation simply uses fseek/ftell.
  37. *
  38. *Entry:
  39. * FILE *stream = pointer to a file stream value
  40. * fpos_t *pos = pointer to a file position value
  41. *
  42. *Exit:
  43. * Successful fgetpos call returns 0.
  44. * Unsuccessful fgetpos call returns non-zero (!0) value and sets
  45. * ERRNO (this is done by ftell and passed back by fgetpos).
  46. *
  47. *Exceptions:
  48. * None.
  49. *
  50. *******************************************************************************/
  51. int __cdecl fgetpos (
  52. FILE *stream,
  53. fpos_t *pos
  54. )
  55. {
  56. #ifdef _POSIX_
  57. if ( (*pos = ftell(stream)) != -1L )
  58. #else
  59. if ( (*pos = _ftelli64(stream)) != -1i64 )
  60. #endif
  61. return(0);
  62. else
  63. return(-1);
  64. }