-
Notifications
You must be signed in to change notification settings - Fork 25
/
DCTar.h
128 lines (112 loc) · 4.36 KB
/
DCTar.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
83
84
85
86
87
88
89
90
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
119
120
121
122
123
124
125
126
127
128
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// DCTar.h
//
// Created by Dalton Cherry on 5/21/14.
//
////////////////////////////////////////////////////////////////////////////////////////////////////
/**
Discussion.
It is important to know that all the file system based tar commands used chunked/buffer methods to save memory.
Due to the fact that tars are normally used to compress lots of content, It is strongly recommend to use those method
versus the in memory data options.
*/
#import <Foundation/Foundation.h>
@interface DCTar : NSObject
/**
Create a gzipped tar file from a file or directory.
@param: filePath is the path to file on disk.
@param: toPath is the path to create the tar at.
@param: error is used to report back if an error happened.
@return if the compression was successful or not.
*/
+(BOOL)compressFileAtPath:(NSString*)filePath toPath:(NSString*)toPath error:(NSError**)error;
/**
Create a gzipped tar file from a data blob.
@param: data is the file data blob to create a tar with.
@param: toPath is the path to create the tar at.
@param: error is used to report back if an error happened.
@return if the compression was successful or not.
*/
//+(BOOL)compressData:(NSData*)data toPath:(NSString*)path error:(NSError**)error;
/**
decompress a tar or gzipped tar (.tar or tar.giz) file.
@param: filePath is the path to the tar file on disk.
@param: toPath is the directory path to create the export data at.
@param: error is used to report back if an error happened.
@return if the decompression was successful or not.
*/
+(BOOL)decompressFileAtPath:(NSString*)filePath toPath:(NSString*)path error:(NSError**)error;
/**
decompress a tar or gzipped tar (.tar or tar.giz) file.
@param: data is the file tar blob to decompress.
@param: toPath is the directory path to create the export data at.
@param: error is used to report back if an error happened.
@return if the decompression was successful or not.
*/
+(BOOL)decompressData:(NSData*)data toPath:(NSString*)path error:(NSError**)error;
/**
Create a tar file (no gzipping) from a file or directory.
@param: filePath is the path to file on disk.
@param: toPath is the path to create the tar at.
@param: error is used to report back if an error happened.
@return if the compression was successful or not.
*/
+(BOOL)tarFileAtPath:(NSString*)tarFilePath toPath:(NSString*)path error:(NSError**)error;
/**
decompress a tar file.
@param: filePath is the path to the tar file on disk.
@param: toPath is the directory path to create the export data at.
@param: error is used to report back if an error happened.
@return if the decompression was successful or not.
*/
+(BOOL)untarFileAtPath:(NSString*)tarFilePath toPath:(NSString*)path error:(NSError**)error;
/**
Create a tar file (not gzipped) from a data blob.
@param: data is the file data blob to create a tar with.
@param: toPath is the path to create the tar at.
@param: error is used to report back if an error happened.
@return if the compression was successful or not.
*/
//+(BOOL)tarData:(NSData*)tarData toPath:(NSString*)path error:(NSError**)error;
/**
decompress a tar file (not gzipped).
@param: data is the file tar blob to decompress.
@param: toPath is the directory path to create the export data at.
@param: error is used to report back if an error happened.
@return if the decompression was successful or not.
*/
+(BOOL)untarData:(NSData*)tarData toPath:(NSString*)path error:(NSError**)error;
/**
gzipped some data.
@param: The data to gzip.
@return The newly gzipped data.
*/
+(NSData*)gzipCompress:(NSData*)data;
/**
decompress a gzipped data blob.
@param: The data to ungzip.
@return The newly unzipped data.
*/
+(NSData*)gzipDecompress:(NSData*)data;
/**
decompress a gzipped file.
@param: filePath is the path to file on disk.
@param: toPath is the path to create the tar at.
@param: error is used to report back if an error happened.
@return if the compression was successful or not.
*/
+(BOOL)gzipDecompress:(NSString*)filePath toPath:(NSString*)toPath error:(NSError**)error;
/**
decompress a zlib data blob.
@param: The data to decompress.
@return The newly decompressed data.
*/
+(NSData*)zlibDecompress:(NSData*)data;
/**
compress a zlib data blob.
@param: The data to compress.
@return The newly compressed data.
*/
+(NSData*)zlibCompress:(NSData*)data;
@end