Differences From Artifact [4c3a4649ab]:
- File
src/OFTarArchive.m
— part of check-in
[23e57c5040]
at
2017-07-22 23:04:35
on branch trunk
— OFFile: Simplify mode
This removes "b" for binary and always uses binary, as there is no good
reason to not use binary. (user: js, size: 2366) [annotate] [blame] [check-ins using]
To Artifact [8e5558d27e]:
- File src/OFTarArchive.m — part of check-in [9104575517] at 2017-08-02 20:11:29 on branch trunk — OFTarArchive: Prepare for adding write support (user: js, size: 2852) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 |
#import "OFTarArchiveEntry.h"
#import "OFTarArchiveEntry+Private.h"
#import "OFStream.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
#endif
#import "OFInvalidFormatException.h"
@implementation OFTarArchive: OFObject
+ (instancetype)archiveWithStream: (OFStream *)stream
{
| > > | > > | > > > | > > > > > > > > > > | | > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
#import "OFTarArchiveEntry.h"
#import "OFTarArchiveEntry+Private.h"
#import "OFStream.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
#endif
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
@implementation OFTarArchive: OFObject
+ (instancetype)archiveWithStream: (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: (OFStream *)stream
mode: (OFString *)mode
{
self = [super init];
@try {
_stream = [stream retain];
if ([mode isEqual: @"r"])
_mode = OF_TAR_ARCHIVE_MODE_READ;
else
@throw [OFInvalidArgumentException exception];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
#ifdef OF_HAVE_FILES
- initWithPath: (OFString *)path
mode: (OFString *)mode
{
OFFile *file = [[OFFile alloc] initWithPath: path
mode: mode];
@try {
self = [self initWithStream: file
mode: mode];
} @finally {
[file release];
}
return self;
}
#endif
|
| ︙ | ︙ | |||
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
{
union {
char c[512];
uint32_t u32[512 / sizeof(uint32_t)];
} buffer;
bool empty = true;
[_lastReturnedEntry of_skip];
[_lastReturnedEntry close];
[_lastReturnedEntry release];
_lastReturnedEntry = nil;
if ([_stream isAtEndOfStream])
return nil;
| > > > | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
{
union {
char c[512];
uint32_t u32[512 / sizeof(uint32_t)];
} buffer;
bool empty = true;
if (_mode != OF_TAR_ARCHIVE_MODE_READ)
@throw [OFInvalidArgumentException exception];
[_lastReturnedEntry of_skip];
[_lastReturnedEntry close];
[_lastReturnedEntry release];
_lastReturnedEntry = nil;
if ([_stream isAtEndOfStream])
return nil;
|
| ︙ | ︙ |