2020-05-05 18:23:03 +00:00
|
|
|
|
/*
|
|
|
|
|
UNALZ : read and extract module for ALZ format.
|
|
|
|
|
|
|
|
|
|
LICENSE (zlib License)
|
|
|
|
|
Copyright (C) 2004-2009 kippler@gmail.com , http://www.kipple.pe.kr
|
|
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
|
appreciated but is not required.
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
|
misrepresented as being the original software.
|
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>Ǵ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD>ִ<EFBFBD> <20>״<EFBFBD><D7B4><EFBFBD>" <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˴ϴ<EFBFBD>. <EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD> <EFBFBD><EFBFBD><EFBFBD>쿡<EFBFBD><EFBFBD> <EFBFBD>ۼ<EFBF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> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
|
|
|
|
|
|
|
|
|
|
=============================================================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2020-05-05 18:22:42 +00:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
# pragma warning( disable : 4786 ) // stl warning <20><><EFBFBD>ֱ<EFBFBD>
|
2020-05-05 18:33:47 +00:00
|
|
|
|
# pragma warning( disable : 4996 ) // crt secure warning
|
2020-05-05 18:22:42 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2020-05-05 18:22:29 +00:00
|
|
|
|
#include <stdio.h>
|
2020-05-05 18:22:35 +00:00
|
|
|
|
#include <iostream>
|
2020-05-05 18:22:42 +00:00
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2020-05-05 18:22:49 +00:00
|
|
|
|
#include <locale.h>
|
2020-05-05 18:22:29 +00:00
|
|
|
|
#include "UnAlz.h"
|
2020-05-05 18:22:42 +00:00
|
|
|
|
#include "UnAlzUtils.h"
|
2020-05-05 18:22:29 +00:00
|
|
|
|
|
2020-05-05 18:22:44 +00:00
|
|
|
|
#include <sys/timeb.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL g_bPipeMode=FALSE;
|
|
|
|
|
|
|
|
|
|
void Copyright()
|
|
|
|
|
{
|
|
|
|
|
// printf("unalz v0.20 (2004/10/22) \n");
|
|
|
|
|
// printf("unalz v0.22 (2004/10/27) \n");
|
|
|
|
|
// printf("unalz v0.23 (2004/10/30) \n");
|
|
|
|
|
// printf("unalz v0.31 (2004/11/27) \n");
|
|
|
|
|
// printf("unalz v0.4 (2005/06/18) \n");
|
|
|
|
|
// printf("unalz v0.5 (2005/07/09) \n");
|
2020-05-05 18:22:47 +00:00
|
|
|
|
// printf("unalz v0.51 (2005/07/24) \n");
|
2020-05-05 18:22:49 +00:00
|
|
|
|
// printf("unalz v0.52 (2005/07/27) \n");
|
|
|
|
|
// printf("unalz v0.53 (2005/10/15) \n");
|
2020-05-05 18:22:51 +00:00
|
|
|
|
// printf("unalz v0.54 (2005/11/21) \n");
|
2020-05-05 18:22:53 +00:00
|
|
|
|
// printf("unalz v0.55 (2006/03/10) \n");
|
2020-05-05 18:22:56 +00:00
|
|
|
|
// printf("unalz v0.60 (2006/12/31) \n");
|
2020-05-05 18:22:58 +00:00
|
|
|
|
// printf("unalz v0.61 (2007/02/10) \n");
|
2020-05-05 18:23:01 +00:00
|
|
|
|
// printf("unalz v0.62 (2008/04/04) \n");
|
2020-05-05 18:23:03 +00:00
|
|
|
|
// printf("unalz v0.63 (2009/01/09) \n");
|
2020-05-05 18:33:47 +00:00
|
|
|
|
// printf("unalz v0.64 (2009/01/20) \n");
|
|
|
|
|
printf("unalz v0.65 (2009/04/01) \n");
|
2020-05-05 18:23:01 +00:00
|
|
|
|
printf("Copyright(C) 2004-2009 by kippler@gmail.com (http://www.kipple.pe.kr) \n");
|
2020-05-05 18:22:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 18:22:29 +00:00
|
|
|
|
|
|
|
|
|
void Usage()
|
|
|
|
|
{
|
2020-05-05 18:22:44 +00:00
|
|
|
|
Copyright();
|
|
|
|
|
|
2020-05-05 18:22:29 +00:00
|
|
|
|
printf("\n");
|
2020-05-05 18:22:42 +00:00
|
|
|
|
/*
|
2020-05-05 18:22:31 +00:00
|
|
|
|
#ifdef _UNALZ_ICONV
|
2020-05-05 18:22:38 +00:00
|
|
|
|
printf("USAGE : unalz [ -utf8 | -cp949 | -euc-kr ] sourcefile.alz [dest path] \n");
|
2020-05-05 18:22:31 +00:00
|
|
|
|
# ifdef _UNALZ_UTF8
|
|
|
|
|
printf(" -utf8 : convert filename's codepage to UTF-8 (default)\n");
|
|
|
|
|
printf(" -cp949 : convert filename's codepage to CP949\n");
|
2020-05-05 18:22:33 +00:00
|
|
|
|
printf(" -euc-kr: convert filename's codepage to EUC-KR\n");
|
2020-05-05 18:22:31 +00:00
|
|
|
|
# else
|
|
|
|
|
printf(" -utf8 : convert filename's codepage to UTF-8\n");
|
|
|
|
|
printf(" -cp949 : convert filename's codepage to CP949 (default)\n");
|
2020-05-05 18:22:33 +00:00
|
|
|
|
printf(" -euc-kr: convert filename's codepage to EUC-KR\n");
|
2020-05-05 18:22:31 +00:00
|
|
|
|
# endif // _UNALZ_UTF8
|
|
|
|
|
#else // no iconv
|
2020-05-05 18:22:29 +00:00
|
|
|
|
printf("USAGE : unalz sourcefile.alz [dest path] \n");
|
2020-05-05 18:22:31 +00:00
|
|
|
|
#endif // _UNALZ_ICONV
|
2020-05-05 18:22:42 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("Usage : unalz [<switches>...] archive.alz [<file names to extract>...]\n");
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf("<switches>\n");
|
|
|
|
|
#ifdef _UNALZ_ICONV
|
|
|
|
|
# ifdef _UNALZ_UTF8
|
|
|
|
|
printf(" -utf8 : convert filename's codepage to UTF-8 (default)\n");
|
|
|
|
|
printf(" -cp949 : convert filename's codepage to CP949\n");
|
|
|
|
|
printf(" -euc-kr : convert filename's codepage to EUC-KR\n");
|
|
|
|
|
# else
|
|
|
|
|
printf(" -utf8 : convert filename's codepage to UTF-8\n");
|
|
|
|
|
printf(" -cp949 : convert filename's codepage to CP949 (default)\n");
|
|
|
|
|
printf(" -euc-kr : convert filename's codepage to EUC-KR\n");
|
|
|
|
|
# endif // _UNALZ_UTF8
|
|
|
|
|
#endif // _UNALZ_ICONV
|
|
|
|
|
printf(" -l : list contents of archive\n");
|
|
|
|
|
printf(" -d directory : set output directory\n");
|
2020-05-05 18:22:44 +00:00
|
|
|
|
printf(" -p : extract files to pipe, no messages\n");
|
|
|
|
|
printf(" -pwd <pwd> : set password\n");
|
2020-05-05 18:22:42 +00:00
|
|
|
|
|
2020-05-05 18:22:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 18:22:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-05-05 18:22:53 +00:00
|
|
|
|
void UnAlzCallback(const char* szFileName, INT64 nCurrent, INT64 nRange, void* param, BOOL* bHalt)
|
2020-05-05 18:22:29 +00:00
|
|
|
|
{
|
2020-05-05 18:22:44 +00:00
|
|
|
|
if(g_bPipeMode) return; // slient
|
|
|
|
|
|
2020-05-05 18:22:53 +00:00
|
|
|
|
#define MSG_BUF_LEN 1024
|
2020-05-05 18:22:29 +00:00
|
|
|
|
// progress
|
2020-05-05 18:22:53 +00:00
|
|
|
|
static char szMessage[MSG_BUF_LEN]={0};
|
|
|
|
|
static INT64 nPrevPercent = -1;
|
2020-05-05 18:22:29 +00:00
|
|
|
|
INT64 percent;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ϸ<EFBFBD> <20><><EFBFBD><EFBFBD>..
|
2020-05-05 18:22:56 +00:00
|
|
|
|
if(szFileName)
|
2020-05-05 18:22:29 +00:00
|
|
|
|
{
|
2020-05-05 18:22:33 +00:00
|
|
|
|
printf("\n");
|
|
|
|
|
#ifdef _WIN32
|
2020-05-05 18:22:53 +00:00
|
|
|
|
_snprintf(szMessage, MSG_BUF_LEN, "unalziiiing : %s (%I64dbytes) ", szFileName, nRange);
|
2020-05-05 18:22:33 +00:00
|
|
|
|
#else
|
2020-05-05 18:22:53 +00:00
|
|
|
|
snprintf(szMessage, MSG_BUF_LEN, "unalziiiing : %s (%lldbytes) ", szFileName, nRange);
|
2020-05-05 18:22:33 +00:00
|
|
|
|
#endif
|
2020-05-05 18:23:03 +00:00
|
|
|
|
printf("%s.", szMessage);
|
2020-05-05 18:22:33 +00:00
|
|
|
|
fflush(stdout);
|
2020-05-05 18:22:29 +00:00
|
|
|
|
nPrevPercent = -1;
|
2020-05-05 18:22:33 +00:00
|
|
|
|
return;
|
2020-05-05 18:22:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
percent = nCurrent*100/nRange;
|
|
|
|
|
|
2020-05-05 18:22:33 +00:00
|
|
|
|
if(nPrevPercent/10==percent/10) return; // <20>ʹ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>..
|
2020-05-05 18:22:29 +00:00
|
|
|
|
nPrevPercent = percent;
|
2020-05-05 18:22:33 +00:00
|
|
|
|
|
|
|
|
|
printf(".");
|
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
2020-05-05 18:22:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 18:22:31 +00:00
|
|
|
|
|
2020-05-05 18:22:29 +00:00
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
|
{
|
2020-05-05 18:22:47 +00:00
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
|
|
2020-05-05 18:22:29 +00:00
|
|
|
|
if(argc<2)
|
|
|
|
|
{
|
|
|
|
|
Usage();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 18:22:31 +00:00
|
|
|
|
CUnAlz unalz;
|
|
|
|
|
char* source=NULL;
|
2020-05-05 18:23:01 +00:00
|
|
|
|
const char* destpath=".";
|
|
|
|
|
const char* destcodepage=NULL;
|
2020-05-05 18:22:44 +00:00
|
|
|
|
char* password=NULL;
|
2020-05-05 18:22:42 +00:00
|
|
|
|
int count;
|
|
|
|
|
BOOL listMode = FALSE;
|
|
|
|
|
vector<string> filelist;
|
2020-05-05 18:22:31 +00:00
|
|
|
|
|
2020-05-05 18:22:42 +00:00
|
|
|
|
/* old method
|
|
|
|
|
for (count=1 ; count < argc && argv[count][0] == '-'; ++count)
|
2020-05-05 18:22:31 +00:00
|
|
|
|
{
|
2020-05-05 18:22:42 +00:00
|
|
|
|
#ifdef _UNALZ_ICONV
|
|
|
|
|
// utf8 <20>ɼ<EFBFBD> ó<><C3B3>
|
|
|
|
|
if(strcmp(argv[count], "-utf8")==0)
|
|
|
|
|
{
|
|
|
|
|
destcodepage = "UTF-8"; // utf-8 support
|
|
|
|
|
}
|
|
|
|
|
else if(strcmp(argv[count], "-cp949")==0)
|
|
|
|
|
{
|
|
|
|
|
destcodepage = "CP949"; // cp949
|
|
|
|
|
}
|
|
|
|
|
else if(strcmp(argv[count], "-euc-kr")==0)
|
|
|
|
|
{
|
|
|
|
|
destcodepage = "EUC-KR"; // EUC-KR
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
if(strcmp(argv[count], "-l")==0 || strcmp(argv[count], "-list")==0)
|
|
|
|
|
{
|
|
|
|
|
listMode = TRUE;
|
|
|
|
|
}
|
2020-05-05 18:22:33 +00:00
|
|
|
|
}
|
2020-05-05 18:22:29 +00:00
|
|
|
|
|
2020-05-05 18:22:42 +00:00
|
|
|
|
#ifdef _UNALZ_ICONV
|
|
|
|
|
if(count>=argc) {Usage();return 0;} // <20>ɼǸ<C9BC> <20><><EFBFBD><EFBFBD> <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>..
|
2020-05-05 18:22:31 +00:00
|
|
|
|
if(destcodepage) unalz.SetDestCodepage(destcodepage);
|
|
|
|
|
#endif
|
2020-05-05 18:22:29 +00:00
|
|
|
|
|
2020-05-05 18:22:31 +00:00
|
|
|
|
// <20>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
source=argv[count];
|
|
|
|
|
count++;
|
2020-05-05 18:22:29 +00:00
|
|
|
|
|
2020-05-05 18:22:31 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
if(count<argc)
|
|
|
|
|
{
|
|
|
|
|
destpath = argv[count];
|
|
|
|
|
count++;
|
|
|
|
|
}
|
2020-05-05 18:22:42 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
for (count=1 ; count < argc; count++)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _UNALZ_ICONV
|
|
|
|
|
// utf8 <20>ɼ<EFBFBD> ó<><C3B3>
|
|
|
|
|
if(strcmp(argv[count], "-utf8")==0)
|
|
|
|
|
{
|
|
|
|
|
destcodepage = "UTF-8"; // utf-8 support
|
|
|
|
|
}
|
|
|
|
|
else if(strcmp(argv[count], "-cp949")==0)
|
|
|
|
|
{
|
|
|
|
|
destcodepage = "CP949"; // cp949
|
|
|
|
|
}
|
|
|
|
|
else if(strcmp(argv[count], "-euc-kr")==0)
|
|
|
|
|
{
|
|
|
|
|
destcodepage = "EUC-KR"; // EUC-KR
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
if(strcmp(argv[count], "-l")==0 || strcmp(argv[count], "-list")==0)
|
|
|
|
|
{
|
|
|
|
|
listMode = TRUE;
|
|
|
|
|
}
|
2020-05-05 18:22:44 +00:00
|
|
|
|
else if(strcmp(argv[count], "-p")==0)
|
|
|
|
|
{
|
|
|
|
|
g_bPipeMode = TRUE;
|
|
|
|
|
}
|
2020-05-05 18:22:42 +00:00
|
|
|
|
else if(strcmp(argv[count], "-d")==0) // dest dir
|
|
|
|
|
{
|
|
|
|
|
count++;
|
|
|
|
|
if(count>=argc) {Usage();return 0;} // dest dir <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾҴ<CABE>..
|
|
|
|
|
destpath = argv[count];
|
|
|
|
|
}
|
2020-05-05 18:22:44 +00:00
|
|
|
|
else if(strcmp(argv[count], "-pwd")==0) // pwd
|
|
|
|
|
{
|
|
|
|
|
count++;
|
|
|
|
|
if(count>=argc) {Usage();return 0;} // dest dir <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾҴ<CABE>..
|
|
|
|
|
password = argv[count];
|
|
|
|
|
}
|
2020-05-05 18:22:42 +00:00
|
|
|
|
else // <20>ɼ<EFBFBD><C9BC><EFBFBD> <20>ƴ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(source==NULL) // <20>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
source=argv[count];
|
|
|
|
|
}
|
|
|
|
|
else // <20><><EFBFBD><EFBFBD>Ǯ <20><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
filelist.push_back(argv[count]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(source==NULL) {Usage();return 0;} // <20>ɼǸ<C9BC> <20><><EFBFBD><EFBFBD> <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>..
|
|
|
|
|
|
|
|
|
|
#ifdef _UNALZ_ICONV
|
|
|
|
|
if(destcodepage) unalz.SetDestCodepage(destcodepage);
|
|
|
|
|
#endif
|
2020-05-05 18:22:29 +00:00
|
|
|
|
|
|
|
|
|
|
2020-05-05 18:22:44 +00:00
|
|
|
|
if(g_bPipeMode==FALSE)
|
|
|
|
|
Copyright(); // copyright ǥ<><C7A5>
|
|
|
|
|
|
|
|
|
|
// pipe mode setting
|
|
|
|
|
unalz.SetPipeMode(g_bPipeMode);
|
|
|
|
|
|
2020-05-05 18:22:31 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
2020-05-05 18:22:29 +00:00
|
|
|
|
if(unalz.Open(source)==FALSE)
|
|
|
|
|
{
|
2020-05-05 18:22:38 +00:00
|
|
|
|
if(unalz.GetLastErr()==CUnAlz::ERR_CORRUPTED_FILE)
|
|
|
|
|
{
|
2020-05-05 18:22:42 +00:00
|
|
|
|
printf("It's corrupted file.\n"); // <20>׳<EFBFBD> <20><><EFBFBD><EFBFBD> Ǯ<><C7AE>..
|
2020-05-05 18:22:38 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("file open error : %s\n", source);
|
|
|
|
|
printf("err code(%d) (%s)\n", unalz.GetLastErr(), unalz.GetLastErrStr());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2020-05-05 18:22:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 18:22:42 +00:00
|
|
|
|
if (listMode)
|
|
|
|
|
{
|
|
|
|
|
return ListAlz(&unalz, source);
|
2020-05-05 18:22:35 +00:00
|
|
|
|
}
|
2020-05-05 18:22:42 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(unalz.IsEncrypted())
|
|
|
|
|
{
|
2020-05-05 18:22:44 +00:00
|
|
|
|
if(password) // command line <20><><EFBFBD><EFBFBD> <20><>ȣ<EFBFBD><C8A3> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|
|
|
|
{
|
2020-05-05 18:22:53 +00:00
|
|
|
|
unalz.SetPassword(password);
|
2020-05-05 18:22:44 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-05-05 18:22:58 +00:00
|
|
|
|
char temp[256];
|
2020-05-05 18:22:44 +00:00
|
|
|
|
char pwd[256];
|
|
|
|
|
printf("Enter Password : ");
|
2020-05-05 18:22:58 +00:00
|
|
|
|
fgets(temp,256,stdin);
|
|
|
|
|
sscanf(temp, "%s\n", pwd); // remove \n
|
2020-05-05 18:22:53 +00:00
|
|
|
|
unalz.SetPassword(pwd);
|
2020-05-05 18:22:44 +00:00
|
|
|
|
}
|
2020-05-05 18:22:42 +00:00
|
|
|
|
}
|
2020-05-05 18:22:35 +00:00
|
|
|
|
|
2020-05-05 18:22:44 +00:00
|
|
|
|
if(g_bPipeMode==FALSE)
|
|
|
|
|
printf("\nExtract %s to %s\n", source, destpath);
|
2020-05-05 18:22:29 +00:00
|
|
|
|
|
2020-05-05 18:22:42 +00:00
|
|
|
|
// callback <20>Լ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
unalz.SetCallback(UnAlzCallback, (void*)NULL);
|
2020-05-05 18:22:29 +00:00
|
|
|
|
|
2020-05-05 18:22:42 +00:00
|
|
|
|
if (filelist.empty()==false) // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>.
|
|
|
|
|
{
|
|
|
|
|
vector<string>::iterator i;
|
|
|
|
|
for(i=filelist.begin();i<filelist.end();i++)
|
|
|
|
|
{
|
|
|
|
|
if(unalz.SetCurrentFile(i->c_str())==FALSE)
|
|
|
|
|
{
|
2020-05-05 18:22:44 +00:00
|
|
|
|
if(g_bPipeMode==FALSE)
|
|
|
|
|
printf("filename not matched : %s\n", i->c_str());
|
2020-05-05 18:22:42 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
unalz.ExtractCurrentFile(destpath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>Ǯ<EFBFBD><C7AE>.
|
|
|
|
|
{
|
|
|
|
|
if(unalz.ExtractAll(destpath)==FALSE)
|
|
|
|
|
{
|
2020-05-05 18:22:44 +00:00
|
|
|
|
if(g_bPipeMode==FALSE)
|
|
|
|
|
{
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf("extract %s to %s failed.\n", source, destpath);
|
|
|
|
|
printf("err code(%d) (%s)\n", unalz.GetLastErr(),
|
|
|
|
|
unalz.GetLastErrStr());
|
|
|
|
|
}
|
2020-05-05 18:22:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-05 18:22:44 +00:00
|
|
|
|
if(g_bPipeMode==FALSE)
|
2020-05-05 18:23:03 +00:00
|
|
|
|
printf("\ndone.\n");
|
2020-05-05 18:22:42 +00:00
|
|
|
|
}
|
2020-05-05 18:22:38 +00:00
|
|
|
|
|
2020-05-05 18:22:29 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|