Home > other >  Cocos2d - x unzip the zip file to the sandbox directories according to extract the successful no fil
Cocos2d - x unzip the zip file to the sandbox directories according to extract the successful no fil

Time:09-24

Recently run into problems when decompressing files, extract the path to the box, printout shows I zip file into the number of entries and extract the method using DJZipArchive, but no sandbox directories and struggle, and then think of another way, I'm in the same way that a file is written to, want to create a binary read/write files in the directory, and then write the unzip the files one by one into the file, the results are the path name, write in code as your veteran to see where the problem,

//the file path
Const char * file_path=FileUtils: : getInstance () - & gt; FullPathForFilename (fullPath). C_str ();
The log (" external file path=% s ", file_path);
STD: : string file_str=file_path;
The log (" 345: % s ", file_str c_str ());

//create unzip the zip
DJZipArchive * zip=new DJZipArchive ();
//file_path zip file path
Zip - & gt; UnzipOpenFile (file_path);
//unzip the file path to create
STD: : string zName="nihao";
STD: : string writablePath=FileUtils: : getInstance () - & gt; GetWritablePath ();
STD: : string fullPath2=writablePath + zName;
The log (" fullPath1: % s ", fullPath2 c_str ());
.//const char * chfullPath2=fullPath2 c_str ();
The FILE * FILE=fopen (fullPath2 c_str (), "w");


For (unsigned int j=0; J & lt; FullPath2. The size (); J++) {

Fwrite (fullPath2. Data (), fullPath2. The size (), 2, and the file).

//fputc (fullPath2. The size (), the file).
The fclose (file);
}
//fullPath unzip the file storage path
Zip - & gt; UnzipFileToAndOverWrite (fullPath2, true);

The log (" fullPath2: % s ", fullPath2 c_str ());

}

CodePudding user response:

To personal ah agghh ah
  • Related