7zFile.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* 7zFile.h -- File IO
  2. 2017-04-03 : 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 "7zTypes.h"
  14. EXTERN_C_BEGIN
  15. /* ---------- File ---------- */
  16. typedef struct
  17. {
  18. #ifdef USE_WINDOWS_FILE
  19. HANDLE handle;
  20. #else
  21. FILE *file;
  22. #endif
  23. } CSzFile;
  24. void File_Construct(CSzFile *p);
  25. #if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE)
  26. WRes InFile_Open(CSzFile *p, const char *name);
  27. WRes OutFile_Open(CSzFile *p, const char *name);
  28. #endif
  29. #ifdef USE_WINDOWS_FILE
  30. WRes InFile_OpenW(CSzFile *p, const WCHAR *name);
  31. WRes OutFile_OpenW(CSzFile *p, const WCHAR *name);
  32. #endif
  33. WRes File_Close(CSzFile *p);
  34. /* reads max(*size, remain file's size) bytes */
  35. WRes File_Read(CSzFile *p, void *data, size_t *size);
  36. /* writes *size bytes */
  37. WRes File_Write(CSzFile *p, const void *data, size_t *size);
  38. WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin);
  39. WRes File_GetLength(CSzFile *p, UInt64 *length);
  40. /* ---------- FileInStream ---------- */
  41. typedef struct
  42. {
  43. ISeqInStream vt;
  44. CSzFile file;
  45. } CFileSeqInStream;
  46. void FileSeqInStream_CreateVTable(CFileSeqInStream *p);
  47. typedef struct
  48. {
  49. ISeekInStream vt;
  50. CSzFile file;
  51. } CFileInStream;
  52. void FileInStream_CreateVTable(CFileInStream *p);
  53. typedef struct
  54. {
  55. ISeqOutStream vt;
  56. CSzFile file;
  57. } CFileOutStream;
  58. void FileOutStream_CreateVTable(CFileOutStream *p);
  59. EXTERN_C_END
  60. #endif