Audio plugin host https://kx.studio/carla
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.

win32i64.c 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
  3. See the accompanying file LICENSE, version 2009-Jan-02 or later
  4. (the contents of which are also included in zip.h) for terms of use.
  5. If, for some reason, all these files are missing, the Info-ZIP license
  6. also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
  7. */
  8. /*---------------------------------------------------------------------------
  9. win32/win32i64.c - UnZip 6
  10. 64-bit filesize support for WIN32 Zip and UnZip.
  11. ---------------------------------------------------------------------------*/
  12. #include "../zip.h"
  13. /* --------------------------------------------------- */
  14. /* Large File Support
  15. *
  16. * Initial functions by E. Gordon and R. Nausedat
  17. * 9/10/2003
  18. *
  19. * These implement 64-bit file support for Windows. The
  20. * defines and headers are in win32/osdep.h.
  21. *
  22. * These moved from win32.c by Mike White to avoid conflicts
  23. * in WiZ of same name functions in UnZip and Zip libraries.
  24. * 9/25/04 EG
  25. */
  26. #if defined(LARGE_FILE_SUPPORT) && !defined(__CYGWIN__)
  27. # ifdef USE_STRM_INPUT
  28. # ifndef zftello
  29. /* 64-bit buffered ftello
  30. *
  31. * Win32 does not provide a 64-bit buffered
  32. * ftell (in the published api anyway) so below provides
  33. * hopefully close version.
  34. * We have not gotten _telli64 to work with buffered
  35. * streams. Below cheats by using fgetpos improperly and
  36. * may not work on other ports.
  37. */
  38. zoff_t zftello(stream)
  39. FILE *stream;
  40. {
  41. fpos_t fpos = 0;
  42. if (fgetpos(stream, &fpos) != 0) {
  43. return -1L;
  44. } else {
  45. return fpos;
  46. }
  47. }
  48. # endif /* ndef zftello */
  49. # ifndef zfseeko
  50. /* 64-bit buffered fseeko
  51. *
  52. * Win32 does not provide a 64-bit buffered
  53. * fseeko, so use _lseeki64 and fflush. Note
  54. * that SEEK_CUR can lose track of location
  55. * if fflush is done between the last buffered
  56. * io and this call.
  57. */
  58. int zfseeko(stream, offset, origin)
  59. FILE *stream;
  60. zoff_t offset;
  61. int origin;
  62. {
  63. /* fseek() or its replacements are supposed to clear the eof status
  64. of the stream. fflush() and _lseeki64() do not touch the stream's
  65. eof flag, so we have to do it manually. */
  66. #if ((defined(_MSC_VER) && (_MSC_VER >= 1200)) || \
  67. (defined(__MINGW32__) && defined(__MSVCRT_VERSION__)))
  68. /* For the MSC environment (VS 6 or higher), and for recent releases of
  69. the MinGW environment, we "know" the internals of the FILE structure.
  70. So, we can clear just the EOF bit of the status flag. */
  71. stream->_flag &= ~_IOEOF;
  72. #else
  73. /* Unfortunately, there is no standard "cleareof()" function, so we have
  74. to use clearerr(). This has the unwanted side effect of clearing the
  75. ferror() state as well. */
  76. clearerr(stream);
  77. #endif
  78. if (origin == SEEK_CUR) {
  79. /* instead of synching up lseek easier just to figure and
  80. use an absolute offset */
  81. offset += zftello(stream);
  82. origin = SEEK_SET;
  83. }
  84. fflush(stream);
  85. if (_lseeki64(fileno(stream), offset, origin) == (zoff_t)-1L) {
  86. return -1;
  87. } else {
  88. return 0;
  89. }
  90. }
  91. # endif /* ndef fseeko */
  92. # endif /* USE_STRM_INPUT */
  93. #endif /* Win32 LARGE_FILE_SUPPORT */
  94. #if 0
  95. FILE* zfopen(filename, mode)
  96. const char *filename;
  97. const char *mode;
  98. {
  99. FILE* fTemp;
  100. fTemp = fopen(filename, mode);
  101. if( fTemp == NULL )
  102. return NULL;
  103. /* sorry, could not make VC60 and its rtl work properly without setting the
  104. * file buffer to NULL. the problem seems to be _telli64 which seems to
  105. * return the max stream position, comments are welcome
  106. */
  107. setbuf(fTemp, NULL);
  108. return fTemp;
  109. }
  110. #endif
  111. /* --------------------------------------------------- */