当前位置: 首页>>代码示例>>C++>>正文


C++ zipClose函数代码示例

本文整理汇总了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);
}
开发者ID:jeremyfry,项目名称:PocketSNES,代码行数:52,代码来源:savestateio.cpp

示例2: zipClose

void ZipFileHandler::OnHandleDestroy(HandleType_t, void *object)
{
    if (NULL != object)
    {
        zipClose((zipFile)object, NULL);
    }
}
开发者ID:pmrowla,项目名称:sm-zip,代码行数:7,代码来源:smzip.cpp

示例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);
	}
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:38,代码来源:PathEstimator.cpp

示例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;
}
开发者ID:Gamer125,项目名称:wiibrowser,代码行数:31,代码来源:ZipFile.cpp

示例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;
}
开发者ID:kindleStudy,项目名称:sumatrapdf,代码行数:29,代码来源:ZipUtil.cpp

示例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");
	}
}
开发者ID:GlPortal,项目名称:Update-Installer,代码行数:30,代码来源:FileUtils.cpp

示例7: zipClose

//-----------------------------------------------------------------------------
// CZLib::Close
//
// Close open zip file
//
void CZLib::Close()
{
   if (m_zf)
      zipClose(m_zf, NULL);

   m_zf = 0;
}
开发者ID:fatterbetter,项目名称:ZTools,代码行数:12,代码来源:zlibcpp.cpp

示例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;
}
开发者ID:valentinos,项目名称:ModMine,代码行数:25,代码来源:quazip.cpp

示例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;
}
开发者ID:tin-pot,项目名称:sumatrapdf,代码行数:36,代码来源:ZipUtil.cpp

示例10: zipClose

bool ZipFile::Close(QString comment)
{
	if (!zf)
		return false;
	bool success = zipClose(zf, comment.toAscii().constData()) == ZIP_OK;
	zf = NULL;
	return success;
}
开发者ID:timo-e,项目名称:MobileMaps,代码行数:8,代码来源:zipfile.cpp

示例11: ClearList

ZipFile::~ZipFile()
{
    ClearList();
    if(uzFile)
        unzClose(uzFile);
    if(zFile)
        zipClose(zFile, NULL);
}
开发者ID:Gamer125,项目名称:wiibrowser,代码行数:8,代码来源:ZipFile.cpp

示例12: zipClose

void ZipArchive::close()
{
	if (!isOpen())
		return;
	
	zipClose(d->zip, 0);
	d->zip = 0;
}
开发者ID:h2so5,项目名称:PaintField,代码行数:8,代码来源:zip.cpp

示例13: close_ZIP_archive

void
close_ZIP_archive(void)
{
	if (unzipping)
		unzClose(unzip_handle);
	else
		zipClose(zip_handle, NULL);
}
开发者ID:docbrown,项目名称:3dml,代码行数:8,代码来源:Parser.cpp

示例14: zipClose

		ZipArchiveImpl::~ZipArchiveImpl()
		{
			int r = ZIP_OK;
			if (m_File)
				r = zipClose(m_File, ":)");
			m_File = nullptr;
			m_Info = ArchiveInfo();
		}
开发者ID:Kezeali,项目名称:Fusion,代码行数:8,代码来源:FusionZipArchive.cpp

示例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;
}
开发者ID:andyTsing,项目名称:freedownload,代码行数:58,代码来源:fsUploadMgr.cpp


注:本文中的zipClose函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。