Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/dep/lzma/include/7zFile.h
4255 views
1
/* 7zFile.h -- File IO
2
2023-03-05 : Igor Pavlov : Public domain */
3
4
#ifndef ZIP7_INC_FILE_H
5
#define ZIP7_INC_FILE_H
6
7
#ifdef _WIN32
8
#define USE_WINDOWS_FILE
9
// #include <windows.h>
10
#endif
11
12
#ifdef USE_WINDOWS_FILE
13
#include "7zWindows.h"
14
15
#else
16
// note: USE_FOPEN mode is limited to 32-bit file size
17
// #define USE_FOPEN
18
// #include <stdio.h>
19
#endif
20
21
#include "7zTypes.h"
22
23
EXTERN_C_BEGIN
24
25
/* ---------- File ---------- */
26
27
typedef struct
28
{
29
#ifdef USE_WINDOWS_FILE
30
HANDLE handle;
31
#elif defined(USE_FOPEN)
32
FILE *file;
33
#else
34
int fd;
35
#endif
36
} CSzFile;
37
38
void File_Construct(CSzFile *p);
39
#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE)
40
WRes InFile_Open(CSzFile *p, const char *name);
41
WRes OutFile_Open(CSzFile *p, const char *name);
42
#endif
43
#ifdef USE_WINDOWS_FILE
44
WRes InFile_OpenW(CSzFile *p, const WCHAR *name);
45
WRes OutFile_OpenW(CSzFile *p, const WCHAR *name);
46
#endif
47
WRes File_Close(CSzFile *p);
48
49
/* reads max(*size, remain file's size) bytes */
50
WRes File_Read(CSzFile *p, void *data, size_t *size);
51
52
/* writes *size bytes */
53
WRes File_Write(CSzFile *p, const void *data, size_t *size);
54
55
WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin);
56
WRes File_GetLength(CSzFile *p, UInt64 *length);
57
58
59
/* ---------- FileInStream ---------- */
60
61
typedef struct
62
{
63
ISeqInStream vt;
64
CSzFile file;
65
WRes wres;
66
} CFileSeqInStream;
67
68
void FileSeqInStream_CreateVTable(CFileSeqInStream *p);
69
70
71
typedef struct
72
{
73
ISeekInStream vt;
74
CSzFile file;
75
WRes wres;
76
} CFileInStream;
77
78
void FileInStream_CreateVTable(CFileInStream *p);
79
80
81
typedef struct
82
{
83
ISeqOutStream vt;
84
CSzFile file;
85
WRes wres;
86
} CFileOutStream;
87
88
void FileOutStream_CreateVTable(CFileOutStream *p);
89
90
EXTERN_C_END
91
92
#endif
93
94