Esempio n. 1
0
int XSYNCZIP_getEntryFileByName ( XDRM_CTRL_CONTEXT_PTR pCtx,  char *desiredName, char *path )
{
#if 0
   chdir ( path );
   return do_extract_onefile ( ( unzFile ) pCtx->pZipFile, desiredName, 0, 0, NULL, path );
#else
   return NOT_IMPLEMENTED_YET;
#endif
}
Esempio n. 2
0
int XSYNCZIP_getEntryFileByIdx ( XDRM_CTRL_CONTEXT_PTR pCtx,  int idx, char *path )
{
#if 0
   char *name;
   if ( NULL!=name ) {
      return do_extract_onefile ( ( unzFile ) pCtx->pZipFile, name, 0, 0, NULL , path );
   } else
      return -1;
#else
   return NOT_IMPLEMENTED_YET;
#endif
}
Esempio n. 3
0
QString FileUnzip::getFile(QString name)
{
	QString pwd = QDir::currentPath();
	QString outDir = ScPaths::getTempFileDir();
	QFile f(outDir);
	QFileInfo fi(f);
	if (!fi.isWritable())
		outDir = ScPaths::getApplicationDataDir();
	QDir::setCurrent(outDir);
	unzFile uf = unzOpenFile(zipFile);
	int ret = do_extract_onefile(uf,name, 0, 1, NULL);
	unzCloseCurrentFile(uf);
	QDir::setCurrent(pwd);
	if (ret != 0)
		return NULL;
	else
		return outDir + name;
}
Esempio n. 4
0
File: miniunz.c Progetto: pingicx/cx
int main(int argc,char *argv[])
{
    char zipfilename[MAXFILENAME]= {0};
    char filename_to_extract[MAXFILENAME]= {0};
    const char *password=NULL;
    char filename_try[MAXFILENAME+16] = "";
    int i;
    int ret_value=0;
    int opt_do_list=0;
    int opt_do_extract=1;
    int opt_do_extract_withoutpath=0;
    int opt_overwrite=0;
    int opt_extractdir=0;
    char dirname[MAXFILENAME]= {0};
    unzFile uf=NULL;

    do_banner();
    if (argc==1)
    {
        do_help();
        return 0;
    }
    else
    {
        for (i=1; i<argc; i++)
        {
            if ((*argv[i])=='-')
            {
                const char *p=argv[i]+1;

                while ((*p)!='\0')
                {
                    char c=*(p++);;
                    if ((c=='l') || (c=='L'))
                        opt_do_list = 1;
                    if ((c=='v') || (c=='V'))
                        opt_do_list = 1;
                    if ((c=='x') || (c=='X'))
                        opt_do_extract = 1;
                    if ((c=='e') || (c=='E'))
                        opt_do_extract = opt_do_extract_withoutpath = 1;
                    if ((c=='o') || (c=='O'))
                        opt_overwrite=1;
                    if ((c=='d') || (c=='D'))
                    {
                        opt_extractdir=1;
                        strcat(dirname,__DIR__);
                        strcat(dirname,"/");
                        strcat(dirname,argv[i+1]);
                    }

                    if (((c=='p') || (c=='P')) && (i+1<argc))
                    {
                        password=argv[i+1];
                        i++;
                    }
                }
            }
            else
            {
                if (!strlen(zipfilename))
                {
                    strcat(zipfilename,__DIR__);
                    strcat(zipfilename,"/");
                    strcat(zipfilename,argv[i]);
                }
                else if ((!strlen(filename_to_extract)) && (!opt_extractdir))
                {
                    strcat(filename_to_extract,__DIR__);
                    strcat(filename_to_extract,"/");
                    strcat(filename_to_extract,argv[i]);
                }
            }
        }
    }

    if (strlen(zipfilename))
    {

#        ifdef USEWIN32IOAPI
        zlib_filefunc64_def ffunc;
#        endif

        strncpy(filename_try, zipfilename,MAXFILENAME-1);
        /* strncpy doesnt append the trailing NULL, of the string is too long. */
        filename_try[ MAXFILENAME ] = 0;

#        ifdef USEWIN32IOAPI
        fill_win32_filefunc64A(&ffunc);
        uf = unzOpen2_64(zipfilename,&ffunc);
#        else
        uf = unzOpen64(zipfilename);
#        endif
        if (uf==NULL)
        {
            strcat(filename_try,".zip");
#            ifdef USEWIN32IOAPI
            uf = unzOpen2_64(filename_try,&ffunc);
#            else
            uf = unzOpen64(filename_try);
#            endif
        }
    }

    if (uf==NULL)
    {
        printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename);
        return 1;
    }
    printf("%s opened\n",filename_try);

    if (opt_do_list==1)
        ret_value = do_list(uf);
    else if (opt_do_extract==1)
    {
        chdir(__DIR__);
#ifdef _WIN32
        if (opt_extractdir && _chdir(dirname))
#else
        if (opt_extractdir && chdir(dirname))
#endif
        {
            printf("Error changing into %s, aborting\n", dirname);
            exit(-1);
        }

        if (!strlen(filename_to_extract))
            ret_value = do_extract(uf, opt_do_extract_withoutpath, opt_overwrite, password);
        else
            ret_value = do_extract_onefile(uf, filename_to_extract, opt_do_extract_withoutpath, opt_overwrite, password);
    }

    unzClose(uf);

    return ret_value;
}
Esempio n. 5
0
/// @brief ÉèÖÃGIF¶¯»­Í¼Æ¬,´ÓZIPѹËõ°üÖмÓÔØͼƬ.
/// @param hEle  ÔªËؾä±ú.
/// @param pZipFileName  ѹËõ°üÎļþ.
/// @param pImageName    GIFͼƬÃû.
/// @param pPassword     ѹËõ°üÃÜÂë.
void WINAPI XGif_SetImageZip(HELE hEle,wchar_t *pZipFileName,wchar_t *pImageName,wchar_t *pPassword)
{
	IsGifDebug(hEle,__FUNCTION__);
	gif_ *pObject=(gif_*)hEle;

	if(pObject->pGif)
	{
		delete pObject->pGif;
		pObject->pGif=NULL;
	}


	if(NULL==pZipFileName || NULL==pImageName)
	{
		return ;
	}

	IsImageTypeDebug(_T(__FUNCTION__),pImageName);

	char zipfilename[MAX_PATH]={0};
	WideCharToMultiByte(CP_ACP,NULL,pZipFileName,wcslen(pZipFileName),zipfilename,MAX_PATH,NULL,NULL);

	char filename_to_extract[MAX_PATH]={0};
	WideCharToMultiByte(CP_ACP,NULL,pImageName,wcslen(pImageName),filename_to_extract,MAX_PATH,NULL,NULL);

	char password[MAX_PATH]={0};
	if(pPassword)
		WideCharToMultiByte(CP_ACP,NULL,pPassword,wcslen(pPassword),password,MAX_PATH,NULL,NULL);

	//const char *password=NULL;
	//char *zipfilename="C:\\Users\\mengfei\\Desktop\\myzip.zip";  //ѹËõ°ü
	//char *filename_to_extract="dirtt/123.txt";   //ÌáÈ¡ÎļþÃû
	//char *filename_to_extract="btn.bmp";   //ÌáÈ¡ÎļþÃû
	
	unzFile zipFile=NULL;
	zipFile = unzOpen64(zipfilename); //´ò¿ªÑ¹Ëõ°ü
	if (zipFile==NULL)
	{
		XTRACE("´ò¿ªZIPѹËõ°üʧ°Ü");
		return ;
	}

	int outSize=0;
	void  *data =NULL;
	if(pPassword)
		data=do_extract_onefile(zipFile, filename_to_extract,password,outSize);
	else
		data=do_extract_onefile(zipFile, filename_to_extract,NULL,outSize);

	unzClose(zipFile);

	if(data)
	{
		HGLOBAL   hJPG   =   ::GlobalAlloc(GMEM_MOVEABLE,   outSize); 
		LPVOID   lpJGP   =   ::GlobalLock(hJPG); 
		memcpy(lpJGP,   data,   outSize); 
		::GlobalUnlock(hJPG);
		LPSTREAM   pstm =NULL;
		HRESULT   hr   =CreateStreamOnHGlobal(hJPG,   TRUE,   &pstm); 
		assert(SUCCEEDED(hr)   &&   pstm); 
		//Image *pImg=Image::FromStream(pstm);
		pObject->pGif=new ImageEx(pstm);
		pstm->Release();
		
		free(data);
			if(Gdiplus::Ok != (pObject->pGif->GetLastStatus()))
		{
			delete pObject->pGif;
			pObject->pGif=NULL;
		}

		if(pObject->pGif->InitAnimation(0,0))
			SetTimer(XEle_GetHWnd(hEle),(int)hEle,100,Gif_TimerProc);
	}
}