7zFile.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* 7zFile.h -- File IO
  2. 2008-11-22 : Igor Pavlov : Public domain */
  3. #ifndef __7Z_FILE_H
  4. #define __7Z_FILE_H
  5. #ifdef _WIN32
  6. #define USE_WINDOWS_FILE
  7. #endif
  8. #ifdef USE_WINDOWS_FILE
  9. #include <windows.h>
  10. #else
  11. #include <stdio.h>
  12. #endif
  13. #include "Types.h"
  14. /* ---------- File ---------- */
  15. typedef struct
  16. {
  17. #ifdef USE_WINDOWS_FILE
  18. HANDLE handle;
  19. #else
  20. FILE *file;
  21. #endif
  22. } CSzFile;
  23. void File_Construct(CSzFile *p);
  24. WRes InFile_Open(CSzFile *p, const char *name);
  25. WRes OutFile_Open(CSzFile *p, const char *name);
  26. WRes File_Close(CSzFile *p);
  27. /* reads max(*size, remain file's size) bytes */
  28. WRes File_Read(CSzFile *p, void *data, size_t *size);
  29. /* writes *size bytes */
  30. WRes File_Write(CSzFile *p, const void *data, size_t *size);
  31. WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin);
  32. WRes File_GetLength(CSzFile *p, UInt64 *length);
  33. /* ---------- FileInStream ---------- */
  34. typedef struct
  35. {
  36. ISeqInStream s;
  37. CSzFile file;
  38. } CFileSeqInStream;
  39. void FileSeqInStream_CreateVTable(CFileSeqInStream *p);
  40. typedef struct
  41. {
  42. ISeekInStream s;
  43. CSzFile file;
  44. } CFileInStream;
  45. void FileInStream_CreateVTable(CFileInStream *p);
  46. typedef struct
  47. {
  48. ISeqOutStream s;
  49. CSzFile file;
  50. } CFileOutStream;
  51. void FileOutStream_CreateVTable(CFileOutStream *p);
  52. #endif