author | Ryan C. Gordon <icculus@icculus.org> |
Wed, 27 Sep 2006 07:05:03 +0000 | |
changeset 780 | 8d029fecde3a |
parent 775 | a8cc6b8a8e9c |
child 782 | 5633b9a0c6b6 |
permissions | -rw-r--r-- |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 |
/* |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 |
* LZMA support routines for PhysicsFS. |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
3 |
* |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 |
* Please see the file LICENSE in the source's root directory. |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 |
* |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 |
* This file written by Dennis Schridde, with some peeking at "7zMain.c" |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 |
* by Igor Pavlov. |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 |
*/ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 |
#if HAVE_CONFIG_H |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 |
# include <config.h> |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 |
#endif |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 |
#if (defined PHYSFS_SUPPORTS_LZMA) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 |
#include <stdlib.h> |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 |
#include <string.h> |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 |
#include "physfs.h" |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 |
#define __PHYSICSFS_INTERNAL__ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 |
#include "physfs_internal.h" |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
24 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
25 |
#define _LZMA_IN_CB |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
26 |
/* Use callback for input data */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
27 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
28 |
/* #define _LZMA_OUT_READ */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
29 |
/* Use read function for output data */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
30 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
31 |
#define _LZMA_PROB32 |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
32 |
/* It can increase speed on some 32-bit CPUs, |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
33 |
but memory usage will be doubled in that case */ |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
35 |
#define _LZMA_SYSTEM_SIZE_T |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
36 |
/* Use system's size_t. You can use it to enable 64-bit sizes supporting */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
37 |
|
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
39 |
#include "7zIn.h" |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
40 |
#include "7zCrc.h" |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
41 |
#include "7zExtract.h" |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
42 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
43 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
44 |
/* 7z internal from 7zIn.c */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
45 |
int TestSignatureCandidate(Byte *testBytes); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
46 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
47 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
48 |
typedef struct _CFileInStream |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
49 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
50 |
ISzInStream InStream; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 |
void *File; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 |
} CFileInStream; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
53 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
54 |
/* Set by LZMA_openArchive, except blockXXX which is handled by LZMA_read() */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
55 |
typedef struct _LZMAarchive |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
56 |
{ |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
57 |
struct _LZMAentry *firstEntry; /* Used for cleanup on shutdown */ |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
58 |
struct _LZMAentry *lastEntry; |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
59 |
CArchiveDatabaseEx db; /* For 7z: Database */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
60 |
CFileInStream stream; /* For 7z: Input file incl. read and seek callbacks */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
61 |
unsigned char *block; /* Currently cached block */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
62 |
size_t blockSize; /* Size of current block */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
63 |
PHYSFS_uint32 blockIndex; /* Index of current block */ |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
64 |
} LZMAarchive; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
66 |
/* Set by LZMA_openRead(), except offset which is set by LZMA_read() */ |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 |
typedef struct _LZMAentry |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 |
{ |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
69 |
struct _LZMAentry *next; /* Used for cleanup on shutdown */ |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 |
struct _LZMAentry *previous; |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
71 |
LZMAarchive *archive; /* Link to corresponding archive */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
72 |
CFileItem *file; /* For 7z: File info, eg. name, size */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
73 |
PHYSFS_uint32 index; /* Index inside the archive */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
74 |
size_t offset; /* Offset inside archive block */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
75 |
PHYSFS_uint32 position; /* Current "virtual" position in file */ |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
76 |
} LZMAentry; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
77 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
78 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
79 |
/* Memory management implementations to be passed to 7z */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
80 |
|
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
81 |
static void *SzAllocPhysicsFS(size_t size) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
82 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
83 |
return ((size == 0) ? NULL : allocator.Malloc(size)); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
84 |
} /* SzAllocPhysicsFS */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
85 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
86 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
87 |
static void SzFreePhysicsFS(void *address) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
88 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
89 |
if (address != NULL) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
90 |
allocator.Free(address); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
91 |
} /* SzFreePhysicsFS */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
92 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
93 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
94 |
/* Filesystem implementations to be passed to 7z */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
95 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
96 |
#ifdef _LZMA_IN_CB |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
97 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
98 |
#define kBufferSize (1 << 12) |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
99 |
static Byte g_Buffer[kBufferSize]; /* !!! FIXME: not thread safe! */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
100 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
101 |
SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxReqSize, |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
102 |
size_t *processedSize) |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
103 |
{ |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
104 |
CFileInStream *s = (CFileInStream *)object; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
105 |
size_t processedSizeLoc; |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
106 |
if (maxReqSize > kBufferSize) |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
107 |
maxReqSize = kBufferSize; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
108 |
processedSizeLoc = __PHYSFS_platformRead(s->File, g_Buffer, 1, maxReqSize); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
109 |
*buffer = g_Buffer; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
110 |
if (processedSize != 0) |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
111 |
*processedSize = processedSizeLoc; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
112 |
return SZ_OK; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
113 |
} /* SzFileReadImp */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
114 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
115 |
#else |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
116 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
117 |
SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size, |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
118 |
size_t *processedSize) |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
119 |
{ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
120 |
CFileInStream *s = (CFileInStream *)object; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
121 |
size_t processedSizeLoc = __PHYSFS_platformRead(s->File, buffer, 1, size); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
122 |
if (processedSize != 0) |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
123 |
*processedSize = processedSizeLoc; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
124 |
return SZ_OK; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
125 |
} /* SzFileReadImp */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
126 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
127 |
#endif |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
128 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
129 |
SZ_RESULT SzFileSeekImp(void *object, CFileSize pos) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
130 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
131 |
CFileInStream *s = (CFileInStream *) object; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
132 |
if (__PHYSFS_platformSeek(s->File, (PHYSFS_uint64) pos)) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
133 |
return SZ_OK; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
134 |
return SZE_FAIL; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
135 |
} /* SzFileSeekImp */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
136 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
137 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
138 |
/* |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
139 |
* Find entry 'name' in 'archive' and report the 'index' back |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
140 |
*/ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
141 |
static int lzma_find_entry(LZMAarchive *archive, const char *name, |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
142 |
PHYSFS_uint32 *index) |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
143 |
{ |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
144 |
for (*index = 0; *index < archive->db.Database.NumFiles; (*index)++) |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
145 |
{ |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
146 |
if (strcmp(archive->db.Database.Files[*index].Name, name) == 0) |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
147 |
return 1; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
148 |
} /* for */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
149 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
150 |
BAIL_MACRO(ERR_NO_SUCH_FILE, 0); |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
151 |
} /* lzma_find_entry */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
152 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
153 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
154 |
/* |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
155 |
* Report the first file index of a directory |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
156 |
*/ |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
157 |
static PHYSFS_sint32 lzma_find_start_of_dir(LZMAarchive *archive, |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
158 |
const char *path, |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
159 |
int stop_on_first_find) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
160 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
161 |
PHYSFS_sint32 lo = 0; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
162 |
PHYSFS_sint32 hi = (PHYSFS_sint32) (archive->db.Database.NumFiles - 1); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
163 |
PHYSFS_sint32 middle; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
164 |
PHYSFS_uint32 dlen = strlen(path); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
165 |
PHYSFS_sint32 retval = -1; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
166 |
const char *name; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
167 |
int rc; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
168 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
169 |
if (*path == '\0') /* root dir? */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
170 |
return(0); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
171 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
172 |
if ((dlen > 0) && (path[dlen - 1] == '/')) /* ignore trailing slash. */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
173 |
dlen--; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
174 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
175 |
while (lo <= hi) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
176 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
177 |
middle = lo + ((hi - lo) / 2); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
178 |
name = archive->db.Database.Files[middle].Name; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
179 |
rc = strncmp(path, name, dlen); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
180 |
if (rc == 0) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
181 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
182 |
char ch = name[dlen]; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
183 |
if ('/' < ch) /* make sure this isn't just a substr match. */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
184 |
rc = -1; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
185 |
else if ('/' > ch) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
186 |
rc = 1; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
187 |
else |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
188 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
189 |
if (stop_on_first_find) /* Just checking dir's existance? */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
190 |
return(middle); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
191 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
192 |
if (name[dlen + 1] == '\0') /* Skip initial dir entry. */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
193 |
return(middle + 1); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
194 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
195 |
/* there might be more entries earlier in the list. */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
196 |
retval = middle; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
197 |
hi = middle - 1; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
198 |
} /* else */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
199 |
} /* if */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
200 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
201 |
if (rc > 0) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
202 |
lo = middle + 1; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
203 |
else |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
204 |
hi = middle - 1; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
205 |
} /* while */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
206 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
207 |
return(retval); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
208 |
} /* lzma_find_start_of_dir */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
209 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
210 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
211 |
/* |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
212 |
* Wrap all 7z calls in this, so the physfs error state is set appropriately. |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
213 |
*/ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
214 |
static int lzma_err(SZ_RESULT rc) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
215 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
216 |
switch (rc) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
217 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
218 |
case SZ_OK: /* Same as LZMA_RESULT_OK */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
219 |
break; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
220 |
case SZE_DATA_ERROR: /* Same as LZMA_RESULT_DATA_ERROR */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
221 |
__PHYSFS_setError(ERR_DATA_ERROR); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
222 |
break; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
223 |
case SZE_OUTOFMEMORY: |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
224 |
__PHYSFS_setError(ERR_OUT_OF_MEMORY); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
225 |
break; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
226 |
case SZE_CRC_ERROR: |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
227 |
__PHYSFS_setError(ERR_CORRUPTED); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
228 |
break; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
229 |
case SZE_NOTIMPL: |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
230 |
__PHYSFS_setError(ERR_NOT_IMPLEMENTED); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
231 |
break; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
232 |
case SZE_FAIL: |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
233 |
__PHYSFS_setError(ERR_UNKNOWN_ERROR); /* !!! FIXME: right? */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
234 |
break; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
235 |
case SZE_ARCHIVE_ERROR: |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
236 |
__PHYSFS_setError(ERR_CORRUPTED); /* !!! FIXME: right? */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
237 |
break; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
238 |
default: |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
239 |
__PHYSFS_setError(ERR_UNKNOWN_ERROR); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
240 |
} /* switch */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
241 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
242 |
return(rc); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
243 |
} /* lzma_err */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
244 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
245 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
246 |
static PHYSFS_sint64 LZMA_read(fvoid *opaque, void *outBuffer, |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
247 |
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
248 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
249 |
LZMAentry *entry = (LZMAentry *) opaque; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
250 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
251 |
PHYSFS_sint64 wantedSize = objSize*objCount; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
252 |
PHYSFS_sint64 remainingSize = entry->file->Size - entry->position; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
253 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
254 |
BAIL_IF_MACRO(wantedSize == 0, NULL, 0); /* quick rejection. */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
255 |
BAIL_IF_MACRO(remainingSize == 0, ERR_PAST_EOF, 0); |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
256 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
257 |
if (remainingSize < wantedSize) |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
258 |
{ |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
259 |
wantedSize = remainingSize - (remainingSize % objSize); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
260 |
objCount = (PHYSFS_uint32) (remainingSize / objSize); |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
261 |
BAIL_IF_MACRO(objCount == 0, ERR_PAST_EOF, 0); /* quick rejection. */ |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
262 |
__PHYSFS_setError(ERR_PAST_EOF); /* this is always true here. */ |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
263 |
} /* if */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
264 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
265 |
size_t fileSize; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
266 |
ISzAlloc allocImp; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
267 |
ISzAlloc allocTempImp; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
268 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
269 |
/* Prepare callbacks for 7z */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
270 |
allocImp.Alloc = SzAllocPhysicsFS; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
271 |
allocImp.Free = SzFreePhysicsFS; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
272 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
273 |
allocTempImp.Alloc = SzAllocPhysicsFS; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
274 |
allocTempImp.Free = SzFreePhysicsFS; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
275 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
276 |
if (lzma_err(SzExtract( |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
277 |
&entry->archive->stream.InStream, /* compressed data */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
278 |
&entry->archive->db, |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
279 |
entry->index, |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
280 |
&entry->archive->blockIndex, /* Index of currently cached block, may be changed by SzExtract */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
281 |
&entry->archive->block, /* Cache of current decompressed block, may be allocated/freed by SzExtract */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
282 |
&entry->archive->blockSize, /* Size of current cache, may be changed by SzExtract */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
283 |
&entry->offset, /* Offset of this file inside the cache block, set by SzExtract */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
284 |
&fileSize, /* Size of this file */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
285 |
&allocImp, |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
286 |
&allocTempImp |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
287 |
)) != SZ_OK) |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
288 |
return -1; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
289 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
290 |
/* Copy wanted bytes over from cache to outBuffer */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
291 |
strncpy(outBuffer, |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
292 |
(void*)(entry->archive->block + entry->offset + entry->position), |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
293 |
wantedSize); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
294 |
entry->position += wantedSize; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
295 |
return objCount; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
296 |
} /* LZMA_read */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
297 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
298 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
299 |
static PHYSFS_sint64 LZMA_write(fvoid *opaque, const void *buf, |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
300 |
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
301 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
302 |
BAIL_MACRO(ERR_NOT_SUPPORTED, -1); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
303 |
} /* LZMA_write */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
304 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
305 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
306 |
static int LZMA_eof(fvoid *opaque) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
307 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
308 |
LZMAentry *entry = (LZMAentry *) opaque; |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
309 |
return (entry->position >= entry->file->Size); |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
310 |
} /* LZMA_eof */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
311 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
312 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
313 |
static PHYSFS_sint64 LZMA_tell(fvoid *opaque) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
314 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
315 |
LZMAentry *entry = (LZMAentry *) opaque; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
316 |
return (entry->position); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
317 |
} /* LZMA_tell */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
318 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
319 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
320 |
static int LZMA_seek(fvoid *opaque, PHYSFS_uint64 offset) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
321 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
322 |
LZMAentry *entry = (LZMAentry *) opaque; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
323 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
324 |
BAIL_IF_MACRO(offset < 0, ERR_SEEK_OUT_OF_RANGE, 0); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
325 |
BAIL_IF_MACRO(offset > entry->file->Size, ERR_PAST_EOF, 0); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
326 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
327 |
entry->position = offset; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
328 |
return 1; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
329 |
} /* LZMA_seek */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
330 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
331 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
332 |
static PHYSFS_sint64 LZMA_fileLength(fvoid *opaque) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
333 |
{ |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
334 |
LZMAentry *entry = (LZMAentry *) opaque; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
335 |
return (entry->file->Size); |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
336 |
} /* LZMA_fileLength */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
337 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
338 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
339 |
static int LZMA_fileClose(fvoid *opaque) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
340 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
341 |
LZMAentry *entry = (LZMAentry *) opaque; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
342 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
343 |
/* Fix archive */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
344 |
if (entry == entry->archive->firstEntry) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
345 |
entry->archive->firstEntry = entry->next; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
346 |
if (entry == entry->archive->lastEntry) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
347 |
entry->archive->lastEntry = entry->previous; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
348 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
349 |
/* Fix neighbours */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
350 |
if (entry->previous != NULL) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
351 |
entry->previous->next = entry->next; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
352 |
if (entry->next != NULL) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
353 |
entry->next->previous = entry->previous; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
354 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
355 |
allocator.Free(entry); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
356 |
entry = NULL; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
357 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
358 |
return(1); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
359 |
} /* LZMA_fileClose */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
360 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
361 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
362 |
static int LZMA_isArchive(const char *filename, int forWriting) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
363 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
364 |
PHYSFS_uint8 sig[k7zSignatureSize]; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
365 |
PHYSFS_uint8 res; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
366 |
void *in; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
367 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
368 |
BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, 0); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
369 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
370 |
in = __PHYSFS_platformOpenRead(filename); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
371 |
BAIL_IF_MACRO(in == NULL, NULL, 0); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
372 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
373 |
if (__PHYSFS_platformRead(in, sig, k7zSignatureSize, 1) != 1) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
374 |
BAIL_MACRO(NULL, 0); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
375 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
376 |
/* Test whether sig is the 7z signature */ |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
377 |
res = TestSignatureCandidate(sig); |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
378 |
|
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
379 |
__PHYSFS_platformClose(in); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
380 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
381 |
return res; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
382 |
} /* LZMA_isArchive */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
383 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
384 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
385 |
static void *LZMA_openArchive(const char *name, int forWriting) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
386 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
387 |
LZMAarchive *archive; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
388 |
ISzAlloc allocImp; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
389 |
ISzAlloc allocTempImp; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
390 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
391 |
BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, NULL); |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
392 |
BAIL_IF_MACRO(!LZMA_isArchive(name, forWriting), ERR_UNSUPPORTED_ARCHIVE, 0); |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
393 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
394 |
archive = (LZMAarchive *) allocator.Malloc(sizeof (LZMAarchive)); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
395 |
BAIL_IF_MACRO(archive == NULL, ERR_OUT_OF_MEMORY, NULL); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
396 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
397 |
archive->block = NULL; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
398 |
archive->firstEntry = NULL; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
399 |
archive->lastEntry = NULL; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
400 |
|
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
401 |
if ((archive->stream.File = __PHYSFS_platformOpenRead(name)) == NULL) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
402 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
403 |
allocator.Free(archive); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
404 |
return NULL; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
405 |
} /* if */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
406 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
407 |
/* Prepare structs for 7z */ |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
408 |
archive->stream.InStream.Read = SzFileReadImp; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
409 |
archive->stream.InStream.Seek = SzFileSeekImp; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
410 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
411 |
allocImp.Alloc = SzAllocPhysicsFS; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
412 |
allocImp.Free = SzFreePhysicsFS; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
413 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
414 |
allocTempImp.Alloc = SzAllocPhysicsFS; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
415 |
allocTempImp.Free = SzFreePhysicsFS; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
416 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
417 |
InitCrcTable(); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
418 |
SzArDbExInit(&archive->db); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
419 |
if (lzma_err(SzArchiveOpen(&archive->stream.InStream, &archive->db, |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
420 |
&allocImp, &allocTempImp)) != SZ_OK) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
421 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
422 |
__PHYSFS_platformClose(archive->stream.File); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
423 |
allocator.Free(archive); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
424 |
return NULL; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
425 |
} /* if */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
426 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
427 |
return(archive); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
428 |
} /* LZMA_openArchive */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
429 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
430 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
431 |
/* |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
432 |
* Moved to seperate function so we can use alloca then immediately throw |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
433 |
* away the allocated stack space... |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
434 |
*/ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
435 |
static void doEnumCallback(PHYSFS_EnumFilesCallback cb, void *callbackdata, |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
436 |
const char *odir, const char *str, PHYSFS_sint32 ln) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
437 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
438 |
char *newstr = alloca(ln + 1); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
439 |
if (newstr == NULL) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
440 |
return; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
441 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
442 |
memcpy(newstr, str, ln); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
443 |
newstr[ln] = '\0'; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
444 |
cb(callbackdata, odir, newstr); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
445 |
} /* doEnumCallback */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
446 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
447 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
448 |
static void LZMA_enumerateFiles(dvoid *opaque, const char *dname, |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
449 |
int omitSymLinks, PHYSFS_EnumFilesCallback cb, |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
450 |
const char *origdir, void *callbackdata) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
451 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
452 |
LZMAarchive *archive = (LZMAarchive *) opaque; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
453 |
PHYSFS_sint32 dlen; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
454 |
PHYSFS_sint32 dlen_inc; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
455 |
PHYSFS_sint32 max; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
456 |
PHYSFS_sint32 i; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
457 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
458 |
i = lzma_find_start_of_dir(archive, dname, 0); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
459 |
if (i == -1) /* no such directory. */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
460 |
return; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
461 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
462 |
dlen = strlen(dname); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
463 |
if ((dlen > 0) && (dname[dlen - 1] == '/')) /* ignore trailing slash. */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
464 |
dlen--; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
465 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
466 |
dlen_inc = ((dlen > 0) ? 1 : 0) + dlen; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
467 |
max = (PHYSFS_sint32) archive->db.Database.NumFiles; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
468 |
while (i < max) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
469 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
470 |
char *add; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
471 |
char *ptr; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
472 |
PHYSFS_sint32 ln; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
473 |
char *e = archive->db.Database.Files[i].Name; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
474 |
if ((dlen) && ((strncmp(e, dname, dlen)) || (e[dlen] != '/'))) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
475 |
break; /* past end of this dir; we're done. */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
476 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
477 |
add = e + dlen_inc; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
478 |
ptr = strchr(add, '/'); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
479 |
ln = (PHYSFS_sint32) ((ptr) ? ptr-add : strlen(add)); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
480 |
doEnumCallback(cb, callbackdata, origdir, add, ln); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
481 |
ln += dlen_inc; /* point past entry to children... */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
482 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
483 |
/* increment counter and skip children of subdirs... */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
484 |
while ((++i < max) && (ptr != NULL)) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
485 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
486 |
char *e_new = archive->db.Database.Files[i].Name; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
487 |
if ((strncmp(e, e_new, ln) != 0) || (e_new[ln] != '/')) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
488 |
break; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
489 |
} /* while */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
490 |
} /* while */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
491 |
} /* LZMA_enumerateFiles */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
492 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
493 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
494 |
static int LZMA_exists(dvoid *opaque, const char *name) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
495 |
{ |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
496 |
LZMAarchive *archive = (LZMAarchive *) opaque; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
497 |
PHYSFS_uint32 index = 0; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
498 |
return(lzma_find_entry(archive, name, &index)); |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
499 |
} /* LZMA_exists */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
500 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
501 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
502 |
static PHYSFS_sint64 LZMA_getLastModTime(dvoid *opaque, |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
503 |
const char *name, |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
504 |
int *fileExists) |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
505 |
{ |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
506 |
/* !!! FIXME: Lacking support in the LZMA C SDK. */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
507 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
508 |
} /* LZMA_getLastModTime */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
509 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
510 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
511 |
static int LZMA_isDirectory(dvoid *opaque, const char *name, int *fileExists) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
512 |
{ |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
513 |
LZMAarchive *archive = (LZMAarchive *) opaque; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
514 |
PHYSFS_uint32 index = 0; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
515 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
516 |
*fileExists = lzma_find_entry(archive, name, &index); |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
517 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
518 |
return(archive->db.Database.Files[index].IsDirectory); |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
519 |
} /* LZMA_isDirectory */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
520 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
521 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
522 |
static int LZMA_isSymLink(dvoid *opaque, const char *name, int *fileExists) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
523 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
524 |
BAIL_MACRO(ERR_NOT_SUPPORTED, 0); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
525 |
} /* LZMA_isSymLink */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
526 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
527 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
528 |
static fvoid *LZMA_openRead(dvoid *opaque, const char *name, int *fileExists) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
529 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
530 |
LZMAarchive *archive = (LZMAarchive *) opaque; |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
531 |
PHYSFS_uint32 index = 0; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
532 |
LZMAentry *entry; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
533 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
534 |
*fileExists = lzma_find_entry(archive, name, &index); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
535 |
BAIL_IF_MACRO(!*fileExists, ERR_NO_SUCH_FILE, NULL); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
536 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
537 |
entry = (LZMAentry *) allocator.Malloc(sizeof (LZMAentry)); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
538 |
BAIL_IF_MACRO(entry == NULL, ERR_OUT_OF_MEMORY, NULL); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
539 |
entry->index = index; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
540 |
entry->archive = archive; |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
541 |
entry->file = archive->db.Database.Files + entry->index; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
542 |
entry->offset = 0; /* Offset will be set by LZMA_read() */ |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
543 |
entry->position = 0; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
544 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
545 |
entry->next = NULL; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
546 |
entry->previous = entry->archive->lastEntry; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
547 |
if (entry->previous != NULL) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
548 |
entry->previous->next = entry; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
549 |
entry->archive->lastEntry = entry; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
550 |
if (entry->archive->firstEntry == NULL) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
551 |
entry->archive->firstEntry = entry; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
552 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
553 |
return(entry); |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
554 |
} /* LZMA_openRead */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
555 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
556 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
557 |
static fvoid *LZMA_openWrite(dvoid *opaque, const char *filename) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
558 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
559 |
BAIL_MACRO(ERR_NOT_SUPPORTED, NULL); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
560 |
} /* LZMA_openWrite */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
561 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
562 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
563 |
static fvoid *LZMA_openAppend(dvoid *opaque, const char *filename) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
564 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
565 |
BAIL_MACRO(ERR_NOT_SUPPORTED, NULL); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
566 |
} /* LZMA_openAppend */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
567 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
568 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
569 |
static void LZMA_dirClose(dvoid *opaque) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
570 |
{ |
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
571 |
LZMAarchive *archive = (LZMAarchive *) opaque; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
572 |
LZMAentry *entry = archive->firstEntry; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
573 |
LZMAentry *tmpEntry = entry; |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
574 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
575 |
while (entry != NULL) |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
576 |
{ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
577 |
tmpEntry = entry->next; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
578 |
LZMA_fileClose(entry); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
579 |
entry = tmpEntry; |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
580 |
} /* while */ |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
581 |
|
780
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
582 |
SzArDbExFree(&archive->db, SzFreePhysicsFS); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
583 |
__PHYSFS_platformClose(archive->stream.File); |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
584 |
|
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
585 |
/* Free the cache which might have been allocated by LZMA_read() */ |
8d029fecde3a
Rewritten 7zip/lzma support (thanks, Dennis!)
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
586 |
allocator.Free(archive->block); |
774
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
587 |
allocator.Free(archive); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
588 |
} /* LZMA_dirClose */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
589 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
590 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
591 |
static int LZMA_remove(dvoid *opaque, const char *name) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
592 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
593 |
BAIL_MACRO(ERR_NOT_SUPPORTED, 0); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
594 |
} /* LZMA_remove */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
595 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
596 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
597 |
static int LZMA_mkdir(dvoid *opaque, const char *name) |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
598 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
599 |
BAIL_MACRO(ERR_NOT_SUPPORTED, 0); |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
600 |
} /* LZMA_mkdir */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
601 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
602 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
603 |
const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_LZMA = |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
604 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
605 |
"7Z", |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
606 |
LZMA_ARCHIVE_DESCRIPTION, |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
607 |
"Dennis Schridde <devurandom@gmx.net>", |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
608 |
"http://icculus.org/physfs/", |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
609 |
}; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
610 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
611 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
612 |
const PHYSFS_Archiver __PHYSFS_Archiver_LZMA = |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
613 |
{ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
614 |
&__PHYSFS_ArchiveInfo_LZMA, |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
615 |
LZMA_isArchive, /* isArchive() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
616 |
LZMA_openArchive, /* openArchive() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
617 |
LZMA_enumerateFiles, /* enumerateFiles() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
618 |
LZMA_exists, /* exists() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
619 |
LZMA_isDirectory, /* isDirectory() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
620 |
LZMA_isSymLink, /* isSymLink() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
621 |
LZMA_getLastModTime, /* getLastModTime() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
622 |
LZMA_openRead, /* openRead() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
623 |
LZMA_openWrite, /* openWrite() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
624 |
LZMA_openAppend, /* openAppend() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
625 |
LZMA_remove, /* remove() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
626 |
LZMA_mkdir, /* mkdir() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
627 |
LZMA_dirClose, /* dirClose() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
628 |
LZMA_read, /* read() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
629 |
LZMA_write, /* write() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
630 |
LZMA_eof, /* eof() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
631 |
LZMA_tell, /* tell() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
632 |
LZMA_seek, /* seek() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
633 |
LZMA_fileLength, /* fileLength() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
634 |
LZMA_fileClose /* fileClose() method */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
635 |
}; |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
636 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
637 |
#endif /* defined PHYSFS_SUPPORTS_LZMA */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
638 |
|
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
639 |
/* end of lzma.c ... */ |
916c2e81e77f
7zip support, written by Dennis Schridde, and heavily Ryanified by me.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
640 |