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
83
84
85
86
|
static OFArc *app;
static void
setPermissions(OFString *destination, OFString *source)
{
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
OFFileManager *fileManager = [OFFileManager defaultManager];
of_file_attributes_t attributes =
[fileManager attributesOfItemAtPath: source];
of_file_attribute_key_t key = of_file_attribute_key_posix_permissions;
of_file_attributes_t destinationAttributes = [OFDictionary
dictionaryWithObject: [attributes objectForKey: key]
forKey: key];
[fileManager setAttributes: destinationAttributes
ofItemAtPath: destination];
#endif
}
static void
setModificationDate(OFString *path, OFGZIPStream *stream)
{
OFDate *modificationDate = stream.modificationDate;
of_file_attributes_t attributes;
if (modificationDate == nil)
return;
attributes = [OFDictionary
dictionaryWithObject: modificationDate
forKey: of_file_attribute_key_modification_date];
[[OFFileManager defaultManager] setAttributes: attributes
ofItemAtPath: path];
}
@implementation GZIPArchive
+ (void)initialize
{
if (self == [GZIPArchive class])
app = (OFArc *)[OFApplication sharedApplication].delegate;
}
+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
mode: (OFString *)mode
encoding: (of_string_encoding_t)encoding
{
return [[[self alloc] initWithStream: stream
mode: mode
encoding: encoding] autorelease];
}
- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream
mode: (OFString *)mode
encoding: (of_string_encoding_t)encoding
{
self = [super init];
@try {
_stream = [[OFGZIPStream alloc] initWithStream: stream
mode: mode];
} @catch (id e) {
|
|
|
|
|
|
|
|
|
|
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
83
84
85
86
|
static OFArc *app;
static void
setPermissions(OFString *destination, OFString *source)
{
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
OFFileManager *fileManager = [OFFileManager defaultManager];
OFFileAttributes attributes = [fileManager
attributesOfItemAtPath: source];
OFFileAttributeKey key = OFFilePOSIXPermissions;
OFFileAttributes destinationAttributes = [OFDictionary
dictionaryWithObject: [attributes objectForKey: key]
forKey: key];
[fileManager setAttributes: destinationAttributes
ofItemAtPath: destination];
#endif
}
static void
setModificationDate(OFString *path, OFGZIPStream *stream)
{
OFDate *modificationDate = stream.modificationDate;
OFFileAttributes attributes;
if (modificationDate == nil)
return;
attributes = [OFDictionary
dictionaryWithObject: modificationDate
forKey: OFFileModificationDate];
[[OFFileManager defaultManager] setAttributes: attributes
ofItemAtPath: path];
}
@implementation GZIPArchive
+ (void)initialize
{
if (self == [GZIPArchive class])
app = (OFArc *)[OFApplication sharedApplication].delegate;
}
+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
mode: (OFString *)mode
encoding: (OFStringEncoding)encoding
{
return [[[self alloc] initWithStream: stream
mode: mode
encoding: encoding] autorelease];
}
- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream
mode: (OFString *)mode
encoding: (OFStringEncoding)encoding
{
self = [super init];
@try {
_stream = [[OFGZIPStream alloc] initWithStream: stream
mode: mode];
} @catch (id e) {
|