#include <XrdOssArcZipFile.hh>
Definition at line 45 of file XrdOssArcZipFile.hh.
◆ XrdOssArcZipFile()
| XrdOssArcZipFile::XrdOssArcZipFile |
( |
const char * | path, |
|
|
int & | rc ) |
Definition at line 60 of file XrdOssArcZipFile.cc.
61{
62 XrdOucEnv zipEnv;
63 int zFD, zrc;
64
65
66
67 if ((zFD = XrdSysFD_Open(path, O_RDONLY)) < 0)
68 {rc = -errno;
69 return;
70 }
71
72
73
74
75 if (
fstat(zFD, &zFStat)) memset(&zFStat, 0,
sizeof(zFStat));
76
77
78
79 zPath = strdup(path);
80
81
82
83 if ((zFile = zip_fdopen(zFD, ZIP_CHECKCONS, &zrc)) == 0)
84 {rc = zip2syserr("fdopen", zrc);
86 return;
87 }
88}
References close, and fstat.
◆ ~XrdOssArcZipFile()
| XrdOssArcZipFile::~XrdOssArcZipFile |
( |
| ) |
|
Definition at line 94 of file XrdOssArcZipFile.cc.
95{
96
97
98 if (zSubFile)
Close();
99
100
101
102 if (zFile)
103 {if (zip_close(zFile))
104 {zipEmsg("close", zip_get_error(zFile));
105 zip_discard(zFile);
106 }
107 zFile = 0;
108 }
109
110
111
112 if (zPath) free(zPath);
113}
References Close().
◆ Close()
| int XrdOssArcZipFile::Close |
( |
| ) |
|
Definition at line 119 of file XrdOssArcZipFile.cc.
120{
121 int zrc = 0;
122
123
124
125 if (zSubFile)
126 {if ((zrc = zip_fclose(zSubFile))) zrc = zip2syserr("close member", zrc);
127 zSubFile = 0;
128 }
129
130
131
132 if (zMember) {free(zMember); zMember = 0;}
133
134
135
136 return zrc;
137}
Referenced by ~XrdOssArcZipFile().
◆ Open()
| int XrdOssArcZipFile::Open |
( |
const char * | member | ) |
|
Definition at line 143 of file XrdOssArcZipFile.cc.
144{
145 int rc;
146
147
148
149 if (zFile == 0) return -EBADF;
150
151
152
153 if (zSubFile)
154 {if ((rc = zip_fclose(zSubFile))) zip2syserr("close", rc, true);
155 free(zMember);
156 zMember = 0;
157 zSubFile = 0;
158 }
159
160
161
162 if (zMember) free(zMember);
163 zMember = strdup(member);
164
165
166
167 zSubFile = zip_fopen(zFile, zMember, 0);
168 if (zSubFile == 0) return zip2syserr("open", zip_get_error(zFile));
169
170
171
172
173
174
175
176 zSeek = true;
177 zOffset = 0;
178
179
180
181 return 0;
182}
◆ Read()
| ssize_t XrdOssArcZipFile::Read |
( |
void * | buff, |
|
|
off_t | offset, |
|
|
size_t | blen ) |
Definition at line 188 of file XrdOssArcZipFile.cc.
189{
190
191
192 if (zSubFile == 0) return -EBADF;
193 if (!blen) return 0;
194
195
196
197 if (offset != zOffset)
198 {if (!zSeek) return -ESPIPE;
199 if (zip_fseek(zSubFile, offset, SEEK_SET))
200 return zip2syserr("seek into", zip_file_get_error(zSubFile));
201 zEOF = false;
202 }
203
204
205
206 if (zEOF) return 0;
207
208
209
210 zip_int64_t ret = zip_fread(zSubFile, buff, blen);
211 if (ret < 0)
212 return zip2syserr("read", zip_file_get_error(zSubFile));
213
214
215
216 zOffset += ret;
217 if (ret < (zip_int64_t)blen) zEOF = true;
218 return ret;
219}
◆ Stat() [1/2]
| int XrdOssArcZipFile::Stat |
( |
const char * | mName, |
|
|
struct stat & | buf ) |
Definition at line 258 of file XrdOssArcZipFile.cc.
259{
260 zip_stat_t zStat;
261
262
263
264 memcpy(&buf, &zFStat,
sizeof(
struct stat));
265
266
267
268 zip_stat_init(&zStat);
269
270
271
272 if (zip_stat(zFile, mName, 0, &zStat) < 0)
273 return zip2syserr("stat", zip_get_error(zFile));
274
275
276
277 if (zStat.valid & ZIP_STAT_INDEX) buf.st_ino = zStat.index;
278 if (zStat.valid & ZIP_STAT_SIZE) buf.st_size = zStat.size;
279
280
281
282 return 0;
283}
References stat.
◆ Stat() [2/2]
| int XrdOssArcZipFile::Stat |
( |
struct stat & | buf | ) |
|
Definition at line 225 of file XrdOssArcZipFile.cc.
226{
227 zip_stat_t zStat;
228
229
230
231 if (zSubFile == 0) return -EBADF;
232
233
234
235 memcpy(&buf, &zFStat,
sizeof(
struct stat));
236
237
238
239 zip_stat_init(&zStat);
240
241
242
243 if (zip_stat(zFile, zMember, 0, &zStat) < 0)
244 return zip2syserr("stat", zip_get_error(zFile));
245
246
247
248 if (zStat.valid & ZIP_STAT_INDEX) buf.st_ino = zStat.index;
249 if (zStat.valid & ZIP_STAT_SIZE) buf.st_size = zStat.size;
250
251
252
253 return 0;
254}
References stat.
The documentation for this class was generated from the following files: