Differences From Artifact [69e4750cf1]:
- File src/OFTarArchive.m — part of check-in [0c5035dd3f] at 2017-08-05 15:22:53 on branch trunk — OFTarArchive: Add write and append support (user: js, size: 10381) [annotate] [blame] [check-ins using]
To Artifact [cb4c96888d]:
- File
src/OFTarArchive.m
— part of check-in
[c404c33cf1]
at
2017-08-05 18:00:22
on branch trunk
— OFZIPArchive: Don't require an OFSeekableStream
This is now only necessary for reading and appending. (user: js, size: 10365) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
69 70 71 72 73 74 75 | memcpy(buffer, [string UTF8String], UTF8StringLength); for (size_t i = UTF8StringLength; i < length; i++) buffer[i] = '\0'; } @implementation OFTarArchive: OFObject | | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
memcpy(buffer, [string UTF8String], UTF8StringLength);
for (size_t i = UTF8StringLength; i < length; i++)
buffer[i] = '\0';
}
@implementation OFTarArchive: OFObject
+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
mode: (OFString *)mode
{
return [[[self alloc] initWithStream: stream
mode: mode] autorelease];
}
#ifdef OF_HAVE_FILES
+ (instancetype)archiveWithPath: (OFString *)path
mode: (OFString *)mode
{
return [[[self alloc] initWithPath: path
mode: mode] autorelease];
}
#endif
- initWithStream: (OF_KINDOF(OFStream *))stream
mode: (OFString *)mode
{
self = [super init];
@try {
_stream = [stream retain];
|
| ︙ | ︙ | |||
112 113 114 115 116 117 118 | uint32_t u32[1024 / sizeof(uint32_t)]; } buffer; bool empty = true; if (![_stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; | | | | | | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
uint32_t u32[1024 / sizeof(uint32_t)];
} buffer;
bool empty = true;
if (![_stream isKindOfClass: [OFSeekableStream class]])
@throw [OFInvalidArgumentException exception];
[stream seekToOffset: -1024
whence: SEEK_END];
[stream readIntoBuffer: buffer.c
exactLength: 1024];
for (size_t i = 0; i < 1024 / sizeof(uint32_t); i++)
if (buffer.u32[i] != 0)
empty = false;
if (!empty)
@throw [OFInvalidFormatException exception];
[stream seekToOffset: -1024
whence: SEEK_END];
}
} @catch (id e) {
[self release];
@throw e;
}
return self;
|
| ︙ | ︙ |