91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
{
self = [super init];
@try {
_stream = [stream retain];
if ([mode isEqual: @"r"])
_mode = OF_LHA_ARCHIVE_MODE_READ;
else if ([mode isEqual: @"w"])
_mode = OF_LHA_ARCHIVE_MODE_WRITE;
else if ([mode isEqual: @"a"])
_mode = OF_LHA_ARCHIVE_MODE_APPEND;
else
@throw [OFInvalidArgumentException exception];
if ((_mode == OF_LHA_ARCHIVE_MODE_WRITE ||
_mode == OF_LHA_ARCHIVE_MODE_APPEND) &&
![_stream isKindOfClass: [OFSeekableStream class]])
@throw [OFInvalidArgumentException exception];
if (_mode == OF_LHA_ARCHIVE_MODE_APPEND)
[(OFSeekableStream *)_stream seekToOffset: 0
whence: SEEK_END];
_encoding = OFStringEncodingISO8859_1;
} @catch (id e) {
[self release];
@throw e;
|
|
|
|
|
|
|
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
{
self = [super init];
@try {
_stream = [stream retain];
if ([mode isEqual: @"r"])
_mode = OFLHAArchiveModeRead;
else if ([mode isEqual: @"w"])
_mode = OFLHAArchiveModeWrite;
else if ([mode isEqual: @"a"])
_mode = OFLHAArchiveModeAppend;
else
@throw [OFInvalidArgumentException exception];
if ((_mode == OFLHAArchiveModeWrite ||
_mode == OFLHAArchiveModeAppend) &&
![_stream isKindOfClass: [OFSeekableStream class]])
@throw [OFInvalidArgumentException exception];
if (_mode == OFLHAArchiveModeAppend)
[(OFSeekableStream *)_stream seekToOffset: 0
whence: SEEK_END];
_encoding = OFStringEncodingISO8859_1;
} @catch (id e) {
[self release];
@throw e;
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
- (OFLHAArchiveEntry *)nextEntry
{
OFLHAArchiveEntry *entry;
char header[21];
size_t headerLen;
if (_mode != OF_LHA_ARCHIVE_MODE_READ)
@throw [OFInvalidArgumentException exception];
[(OFLHAArchiveFileReadStream *)_lastReturnedStream of_skip];
@try {
[_lastReturnedStream close];
} @catch (OFNotOpenException *e) {
/* Might have already been closed by the user - that's fine. */
|
|
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
- (OFLHAArchiveEntry *)nextEntry
{
OFLHAArchiveEntry *entry;
char header[21];
size_t headerLen;
if (_mode != OFLHAArchiveModeRead)
@throw [OFInvalidArgumentException exception];
[(OFLHAArchiveFileReadStream *)_lastReturnedStream of_skip];
@try {
[_lastReturnedStream close];
} @catch (OFNotOpenException *e) {
/* Might have already been closed by the user - that's fine. */
|
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
entry: entry];
return entry;
}
- (OFStream *)streamForReadingCurrentEntry
{
if (_mode != OF_LHA_ARCHIVE_MODE_READ)
@throw [OFInvalidArgumentException exception];
if (_lastReturnedStream == nil)
@throw [OFInvalidArgumentException exception];
return [[(OFLHAArchiveFileReadStream *)_lastReturnedStream
retain] autorelease];
}
- (OFStream *)streamForWritingEntry: (OFLHAArchiveEntry *)entry
{
OFString *compressionMethod;
if (_mode != OF_LHA_ARCHIVE_MODE_WRITE &&
_mode != OF_LHA_ARCHIVE_MODE_APPEND)
@throw [OFInvalidArgumentException exception];
compressionMethod = entry.compressionMethod;
if (![compressionMethod isEqual: @"-lh0-"] &&
![compressionMethod isEqual: @"-lhd-"])
@throw [OFNotImplementedException exceptionWithSelector: _cmd
|
|
|
<
|
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
entry: entry];
return entry;
}
- (OFStream *)streamForReadingCurrentEntry
{
if (_mode != OFLHAArchiveModeRead)
@throw [OFInvalidArgumentException exception];
if (_lastReturnedStream == nil)
@throw [OFInvalidArgumentException exception];
return [[(OFLHAArchiveFileReadStream *)_lastReturnedStream
retain] autorelease];
}
- (OFStream *)streamForWritingEntry: (OFLHAArchiveEntry *)entry
{
OFString *compressionMethod;
if (_mode != OFLHAArchiveModeWrite && _mode != OFLHAArchiveModeAppend)
@throw [OFInvalidArgumentException exception];
compressionMethod = entry.compressionMethod;
if (![compressionMethod isEqual: @"-lh0-"] &&
![compressionMethod isEqual: @"-lhd-"])
@throw [OFNotImplementedException exceptionWithSelector: _cmd
|