Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 将gz转换为zip格式_Objective C_Iphone_Xcode_Ipad - Fatal编程技术网

Objective c 将gz转换为zip格式

Objective c 将gz转换为zip格式,objective-c,iphone,xcode,ipad,Objective C,Iphone,Xcode,Ipad,是否可以使用objective-c将GZ转换为ZIP格式 NSFileManager *fileManger = [NSFileManager defaultManager]; NSError *error; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path = [paths objectAtIndex:0]; path

是否可以使用objective-c将GZ转换为ZIP格式

NSFileManager *fileManger = [NSFileManager defaultManager];
NSError *error;

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [paths objectAtIndex:0];
paths = nil;
path = [path stringByAppendingPathComponent:@"text.zip"];

if([fileManger fileExistsAtPath:path ] == NO){
NSString *testPath = [[NSBundle mainBundle] pathForResource:@"text" ofType:@"gz"];
[fileManger copyItemAtPath:@"" toPath:@"" error:&error]; 
}
将gz文件从mainBundle转换为放在docuemtn目录中的zip文件

但无法通过ZipArchive类打开zip文件。

仅压缩数据,同时是压缩程序和归档程序。gzip流只能压缩一个文件,而ZIP可以压缩多个文件。因此,简单地重命名文件是行不通的


因此,您需要这样做。

通常
。gz
tar
一起使用,所以就是这样。但是,解决方案是解压缩到一个临时目录中,然后使用
zip
@特洛伊木马:对重新打包该目录。但是您需要知道/期望该文件是
tar.gz/tgz
文件,或者检查解压缩后的文件,然后才能进行检查。
.gz
文件中压缩了什么?它是焦油吗?