本文整理汇总了C++中zipClose函数的典型用法代码示例。如果您正苦于以下问题:C++ zipClose函数的具体用法?C++ zipClose怎么用?C++ zipClose使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zipClose函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save_archive
static int save_archive(char *filename, char *buffer, int size)
{
zipFile fd = NULL;
int ret = 0;
fd=zipOpen(filename,0);
if(!fd)
{
printf("Failed to create zip\r\n");
return (0);
}
ret=zipOpenNewFileInZip(fd,"SNAPSHOT",
NULL,
NULL,0,
NULL,0,
NULL,
Z_DEFLATED,
Z_BEST_COMPRESSION);
if(ret != ZIP_OK)
{
zipClose(fd,NULL);
printf("Failed to create file in zip\r\n");
return (0);
}
ret=zipWriteInFileInZip(fd,buffer,size);
if(ret != ZIP_OK)
{
zipCloseFileInZip(fd);
zipClose(fd,NULL);
printf("Failed to write file in zip\r\n");
return (0);
}
ret=zipCloseFileInZip(fd);
if(ret != ZIP_OK)
{
zipClose(fd,NULL);
printf("Failed to close file in zip\r\n");
return (0);
}
ret=zipClose(fd,NULL);
if(ret != ZIP_OK)
{
printf("Failed to close zip\r\n");
return (0);
}
return(1);
}
示例2: zipClose
void ZipFileHandler::OnHandleDestroy(HandleType_t, void *object)
{
if (NULL != object)
{
zipClose((zipFile)object, NULL);
}
}
示例3: f
/*
Trying to write offset and vertices data to file.
*/
void CPathEstimator::WriteFile(string name) {
// We need this directory to exist
boost::filesystem::path f("./maps/paths");
if (!boost::filesystem::exists(f))
boost::filesystem::create_directories(f);
unsigned int hash = Hash();
char hashString[50];
sprintf(hashString,"%u",hash);
string filename = string("maps/paths/") + stupidGlobalMapname.substr(0, stupidGlobalMapname.find('.') + 1) + hashString + "." + name + ".zip";
zipFile file = zipOpen(filename.c_str(), APPEND_STATUS_CREATE);
if (file) {
zipOpenNewFileInZip(file, "pathinfo", NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_BEST_COMPRESSION);
//Write hash.
unsigned int hash = Hash();
zipWriteInFileInZip(file, (void*)&hash, 4);
//Write block-center-offsets.
int blocknr;
for(blocknr = 0; blocknr < nbrOfBlocks; blocknr++) {
zipWriteInFileInZip(file, (void*)blockState[blocknr].sqrCenter, moveinfo->moveData.size() * sizeof(int2));
//file.write((char*)blockState[blocknr].sqrCenter, moveinfo->moveData.size() * sizeof(int2));
}
//Write vertices.
zipWriteInFileInZip(file, (void*)vertex, nbrOfVertices * sizeof(float));
//file.write((char*)vertex, nbrOfVertices * sizeof(float));
zipCloseFileInZip(file);
zipClose(file, NULL);
}
}
示例4: zipClose
bool ZipFile::SwitchMode(short mode)
{
if(mode == ZipFile::OPEN)
{
if(zFile)
{
zipClose(zFile, NULL);
zFile = 0;
}
if(!uzFile)
uzFile = unzOpen(ZipFilePath.c_str());
return (uzFile != 0);
}
else if(mode == ZipFile::CREATE || mode == ZipFile::APPEND)
{
if(uzFile)
{
unzClose(uzFile);
uzFile = 0;
}
if(!zFile)
zFile = zipOpen(ZipFilePath.c_str(), mode);
return (zFile != 0);
}
return false;
}
示例5: fill_win32_filefunc64
bool ZipCreator::SaveAs(const WCHAR *zipFilePath)
{
if (d->pathsAndZipNames.Count() == 0)
return false;
zlib_filefunc64_def ffunc;
fill_win32_filefunc64(&ffunc);
zipFile zf = zipOpen2_64(zipFilePath, 0, NULL, &ffunc);
if (!zf)
return false;
bool result = true;
for (size_t i = 0; i < d->pathsAndZipNames.Count(); i += 2) {
const WCHAR *fileName = d->pathsAndZipNames.At(i);
const WCHAR *nameInZip = d->pathsAndZipNames.At(i + 1);
size_t fileSize;
ScopedMem<char> fileData(file::ReadAll(fileName, &fileSize));
if (!fileData) {
result = false;
break;
}
result = AppendFileToZip(zf, nameInZip, fileData, fileSize);
if (!result)
break;
}
int err = zipClose(zf, NULL);
if (err != ZIP_OK)
result = false;
return result;
}
示例6: throw
void FileUtils::addToZip(const char* archivePath, const char* path, const char* content, int length) throw (IOException)
{
int result = ZIP_OK;
int appendMode = fileExists(archivePath) ? APPEND_STATUS_ADDINZIP : APPEND_STATUS_CREATE;
zipFile archive = zipOpen(archivePath, appendMode);
result = zipOpenNewFileInZip(archive, path, 0 /* file attributes */, 0 /* extra field */, 0 /* extra field size */,
0/* global extra field */, 0 /* global extra field size */, 0 /* comment */, Z_DEFLATED /* method */,
Z_DEFAULT_COMPRESSION /* level */);
if (result != ZIP_OK)
{
throw IOException("Unable to add new file to zip archive");
}
result = zipWriteInFileInZip(archive, content, static_cast<unsigned int>(length));
if (result != ZIP_OK)
{
throw IOException("Unable to write file data to zip archive");
}
result = zipCloseFileInZip(archive);
if (result != ZIP_OK)
{
throw IOException("Unable to close file in zip archive");
}
result = zipClose(archive, 0 /* global comment */);
if (result != ZIP_OK)
{
throw IOException("Unable to close zip archive");
}
}
示例7: zipClose
//-----------------------------------------------------------------------------
// CZLib::Close
//
// Close open zip file
//
void CZLib::Close()
{
if (m_zf)
zipClose(m_zf, NULL);
m_zf = 0;
}
示例8: switch
void QuaZip::close()
{
p->zipError=UNZ_OK;
switch(p->mode) {
case mdNotOpen:
qWarning("QuaZip::close(): ZIP is not open");
return;
case mdUnzip:
p->zipError=unzClose(p->unzFile_f);
break;
case mdCreate:
case mdAppend:
case mdAdd:
p->zipError=zipClose(p->zipFile_f, p->commentCodec->fromUnicode(p->comment).constData());
break;
default:
qWarning("QuaZip::close(): unknown mode: %d", (int)p->mode);
return;
}
// opened by name, need to delete the internal IO device
if (!p->zipName.isEmpty())
delete p->ioDevice;
if(p->zipError==UNZ_OK)
p->mode=mdNotOpen;
}
示例9: fill_win32s_filefunc64
// TODO: using this for XPS files results in documents that Microsoft XPS Viewer can't read
IStream *OpenDirAsZipStream(const WCHAR *dirPath, bool recursive)
{
if (!dir::Exists(dirPath))
return NULL;
ScopedComPtr<IStream> stream;
if (FAILED(CreateStreamOnHGlobal(NULL, TRUE, &stream)))
return NULL;
zlib_filefunc64_def ffunc;
fill_win32s_filefunc64(&ffunc);
zipFile zf = zipOpen2_64(stream, 0, NULL, &ffunc);
if (!zf)
return NULL;
size_t dirLen = str::Len(dirPath);
if (!path::IsSep(dirPath[dirLen - 1]))
dirLen++;
bool ok = true;
DirIter di(dirPath, recursive);
for (const WCHAR *filePath = di.First(); filePath && ok; filePath = di.Next()) {
CrashIf(!str::StartsWith(filePath, dirPath));
const WCHAR *nameInZip = filePath + dirLen;
size_t fileSize;
ScopedMem<char> fileData(file::ReadAll(filePath, &fileSize));
ok = fileData && AppendFileToZip(zf, nameInZip, fileData, fileSize);
}
int err = zipClose(zf, NULL);
if (!ok || err != ZIP_OK)
return NULL;
stream->AddRef();
return stream;
}
示例10: zipClose
bool ZipFile::Close(QString comment)
{
if (!zf)
return false;
bool success = zipClose(zf, comment.toAscii().constData()) == ZIP_OK;
zf = NULL;
return success;
}
示例11: ClearList
ZipFile::~ZipFile()
{
ClearList();
if(uzFile)
unzClose(uzFile);
if(zFile)
zipClose(zFile, NULL);
}
示例12: zipClose
void ZipArchive::close()
{
if (!isOpen())
return;
zipClose(d->zip, 0);
d->zip = 0;
}
示例13: close_ZIP_archive
void
close_ZIP_archive(void)
{
if (unzipping)
unzClose(unzip_handle);
else
zipClose(zip_handle, NULL);
}
示例14: zipClose
ZipArchiveImpl::~ZipArchiveImpl()
{
int r = ZIP_OK;
if (m_File)
r = zipClose(m_File, ":)");
m_File = nullptr;
m_Info = ArchiveInfo();
}
示例15: Event
BOOL fsUploadMgr::ZipFiles ()
{
if (m_bZipFileCreated)
return TRUE;
Event (UMGRE_ZIP_FILES_START);
char szTmpFile [MAX_PATH];
char szTmpPath [MAX_PATH];
GetTempPath (MAX_PATH, szTmpPath);
GetTempFileName (szTmpPath, "tmp", 0, szTmpFile);
m_strUploadFile = szTmpFile;
zipFile zip = zipOpen (m_strUploadFile, 0);
BOOL bOk = TRUE;
m_strZipContentsDescHtml = "<ul>";
for (size_t i = 0; i < m_pkg.m_vPathes.size () && bOk && m_bNeedStop == false; i++)
{
LPCSTR psz = m_pkg.m_vPathes [i];
char szName [1000] = "";
fsGetFileName (psz, szName);
if (GetFileAttributes (psz) & FILE_ATTRIBUTE_DIRECTORY)
{
AddItemToZipContentsDescHtml (szName, _UI64_MAX);
m_strZipContentsDescHtml += "<ul>";
bOk = bOk && Zip_AddFolder (zip, psz, NULL, 1);
m_strZipContentsDescHtml += "</ul>";
}
else
{
bOk = bOk && Zip_AddFile (zip, psz, NULL);
if (bOk)
{
WIN32_FILE_ATTRIBUTE_DATA wfad;
GetFileAttributesEx (psz, GetFileExInfoStandard, &wfad);
AddItemToZipContentsDescHtml (szName, ((UINT64)wfad.nFileSizeHigh << 32) + wfad.nFileSizeLow);
}
}
}
m_strZipContentsDescHtml += "</ul>";
zipClose (zip, NULL);
if (m_bNeedStop || bOk == FALSE)
DeleteFile (m_strUploadFile);
else
m_bZipFileCreated = TRUE;
if (m_bNeedStop == false)
Event (bOk ? UMGRE_ZIP_FILES_DONE : UMGRE_ZIP_FILES_FAILED);
return m_bZipFileCreated;
}