第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

iPhone解壓碼

iPhone解壓碼

iOS
侃侃爾雅 2019-11-26 10:30:09
確實堅持嘗試編寫代碼來解壓縮iPhone上的文件或目錄。以下是一些用于嘗試解壓縮簡單文本文件的示例代碼。它將文件解壓縮,但已損壞。(void)loadView {    NSString *DOCUMENTS_FOLDER = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];    NSString *path = [DOCUMENTS_FOLDER stringByAppendingPathComponent:@"sample.zip"];    NSString *unzipeddest = [DOCUMENTS_FOLDER stringByAppendingPathComponent:@"test.txt"];      gzFile file = gzopen([path UTF8String], "rb");    FILE *dest = fopen([unzipeddest UTF8String], "w");    unsigned char buffer[CHUNK];    int uncompressedLength = gzread(file, buffer, CHUNK);    if(fwrite(buffer, 1, uncompressedLength, dest) != uncompressedLength ||     ferror(dest)) {        NSLog(@"error writing data");    }    else{    }    fclose(dest);    gzclose(file);  }
查看完整描述

3 回答

?
慕蓋茨4494581

TA貢獻1850條經(jīng)驗 獲得超11個贊

我想要一個簡單的解決方案,但在這里找不到我喜歡的解決方案,因此我修改了一個庫以實現(xiàn)自己想要的功能。您可能會發(fā)現(xiàn)SSZipArchive有用。(它也可以順便創(chuàng)建zip文件。)


用法:


NSString *path = @"path_to_your_zip_file";

NSString *destination = @"path_to_the_folder_where_you_want_it_unzipped";

[SSZipArchive unzipFileAtPath:path toDestination:destination];


查看完整回答
反對 回復(fù) 2019-11-26
?
子衿沉夜

TA貢獻1828條經(jīng)驗 獲得超3個贊

對于gzip,這段代碼對我來說效果很好:


數(shù)據(jù)庫是這樣準備的:gzip foo.db


關(guān)鍵是遍歷gzread()。上面的示例僅讀取前CHUNK字節(jié)。


#import <zlib.h>

#define CHUNK 16384



  NSLog(@"testing unzip of database");

  start = [NSDate date];

  NSString *zippedDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"foo.db.gz"];

  NSString *unzippedDBPath = [documentsDirectory stringByAppendingPathComponent:@"foo2.db"];

  gzFile file = gzopen([zippedDBPath UTF8String], "rb");

  FILE *dest = fopen([unzippedDBPath UTF8String], "w");

  unsigned char buffer[CHUNK];

  int uncompressedLength;

  while (uncompressedLength = gzread(file, buffer, CHUNK) ) {

    // got data out of our file

    if(fwrite(buffer, 1, uncompressedLength, dest) != uncompressedLength || ferror(dest)) {

      NSLog(@"error writing data");

    }

  }

  fclose(dest);

  gzclose(file);

  NSLog(@"Finished unzipping database");

順便說一句,我可以在77秒內(nèi)將33MB解壓縮到130MB,或者每秒壓縮約1.7MB。


查看完整回答
反對 回復(fù) 2019-11-26
  • 3 回答
  • 0 關(guān)注
  • 590 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號