mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
reference: plugin/zip demo
git-svn-id: svn://ultimatepp.org/upp/trunk@5393 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
631b59f8f2
commit
698d6cc55a
3 changed files with 52 additions and 0 deletions
35
reference/Zip/Zip.cpp
Normal file
35
reference/Zip/Zip.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include <plugin/zip/zip.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
CONSOLE_APP_MAIN {
|
||||
StdLogSetup(LOG_COUT|LOG_FILE);
|
||||
|
||||
String zipfile = ConfigFile("test.zip");
|
||||
|
||||
// Compression
|
||||
FileZip zip(zipfile);
|
||||
|
||||
zip.WriteFolder("test", GetSysTime());
|
||||
|
||||
const char *somedata = "some data";
|
||||
zip.WriteFile(somedata, strlen(somedata), "somedata.txt");
|
||||
|
||||
zip.WriteFile(String("other data"), "test/otherdata.txt");
|
||||
|
||||
if(zip.Finish())
|
||||
LOG(zipfile << " created succesfully");
|
||||
|
||||
// Decompression
|
||||
FileUnZip unzip(zipfile);
|
||||
while(!(unzip.IsEof() || unzip.IsError())) {
|
||||
LOG("Path:" << unzip.GetPath());
|
||||
LOG(" Time:" << unzip.GetTime());
|
||||
if(!unzip.IsFolder()) {
|
||||
LOG(" Size:" << unzip.GetLength());
|
||||
LOG(" Content:" << unzip.ReadFile());
|
||||
}
|
||||
else
|
||||
unzip.SkipFile();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue