unzipLIB.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2021 BitBank Software, Inc. All Rights Reserved.
  2. // Licensed under the Apache License, Version 2.0 (the "License");
  3. // you may not use this file except in compliance with the License.
  4. // You may obtain a copy of the License at
  5. // http://www.apache.org/licenses/LICENSE-2.0
  6. // Unless required by applicable law or agreed to in writing, software
  7. // distributed under the License is distributed on an "AS IS" BASIS,
  8. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. // See the License for the specific language governing permissions and
  10. // limitations under the License.
  11. //===========================================================================
  12. #ifndef __UNZIPLIB__
  13. #define __UNZIPLIB__
  14. #if defined( PICO_BUILD ) || defined( __MACH__ ) || defined( __LINUX__ ) || defined( __MCUXPRESSO )
  15. #include <stdio.h>
  16. #include <stdint.h>
  17. #include <string.h>
  18. #include <stdlib.h>
  19. #define memcpy_P memcpy
  20. #define PROGMEM
  21. #else
  22. #include <Arduino.h>
  23. #endif
  24. //
  25. // unzip library
  26. // Written by Larry Bank
  27. // Copyright (c) 2021 BitBank Software, Inc.
  28. // bitbank@pobox.com
  29. //
  30. // An embedded-friendly unzip library
  31. // which needs only 41K of RAM
  32. //
  33. #include "unzip.h"
  34. #ifdef __cplusplus
  35. //
  36. // The UNZIP class wraps portable C code which does the actual work
  37. //
  38. class UNZIP
  39. {
  40. public:
  41. int openZIP(uint8_t *pData, int iDataSize);
  42. int openZIP(const char *szFilename, ZIP_OPEN_CALLBACK *pfnOpen, ZIP_CLOSE_CALLBACK *pfnClose, ZIP_READ_CALLBACK *pfnRead, ZIP_SEEK_CALLBACK *pfnSeek);
  43. int closeZIP();
  44. int openCurrentFile();
  45. int closeCurrentFile();
  46. int readCurrentFile(uint8_t *buffer, int iLength);
  47. int getCurrentFilePos();
  48. int gotoFirstFile();
  49. int gotoNextFile();
  50. int locateFile(const char *szFilename);
  51. int getFileInfo(unz_file_info *pFileInfo, char *szFileName, int iFilenameBufferSize, void *extraField, int iExtraFieldBufferSize, char *szComment, int iCommentBufferSize); // get info about the current file
  52. int getLastError();
  53. int getGlobalComment(char *destBuffer, int iBufferSize);
  54. private:
  55. ZIPFILE _zip;
  56. }; // UNZIP class
  57. // Add C interface here
  58. #endif // __cplusplus
  59. #endif // __UNZIPLIB__