Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/wince/intrface.cpp view on Meta::CPAN
}
// Close our thread handle since we have no use for it.
CloseHandle(hThread);
return TRUE;
}
//******************************************************************************
int DoGetComment(LPCSTR szZipFile) {
int result;
// Create our Globals struct and fill it in with some default values.
Uz_Globs *pG = InitGlobals(szZipFile);
if (!pG) {
return PK_MEM;
}
pG->UzO.zflag = TRUE; // display the zipfile comment
// We wrap some exception handling around the entire Info-ZIP engine to be
// safe. Since we are running on a device with tight memory configurations,
// all sorts of problems can arise when we run out of memory.
__try {
// Call the unzip routine. We will catch the comment string in a callback
// to win_fprintf().
result = process_zipfiles(pG);
} __except(EXCEPTION_EXECUTE_HANDLER) {
// Catch any exception here.
DebugOut(TEXT("Exception 0x%08X occurred in DoGetComment()"),
GetExceptionCode());
result = PK_EXCEPTION;
}
// Free our globals.
FreeGlobals(pG);
return result;
}
//******************************************************************************
BOOL SetExtractToDirectory(LPTSTR szDirectory) {
BOOL fNeedToAddWack = FALSE;
// Remove any trailing wack from the path.
int length = _tcslen(szDirectory);
if ((length > 0) && (szDirectory[length - 1] == TEXT('\\'))) {
szDirectory[--length] = TEXT('\0');
fNeedToAddWack = TRUE;
}
#ifndef _WIN32_WCE
// Check to see if a root directory was specified.
if ((length == 2) && isalpha(szDirectory[0]) && (szDirectory[1] == ':')) {
// If just a root is specified, we need to only verify the drive letter.
if (!(GetLogicalDrives() & (1 << (tolower(szDirectory[0]) - (int)'a')))) {
// This drive does not exist. Bail out with a failure.
return FALSE;
}
} else
#endif
// We only verify path if length is >0 since we know "\" is valid.
if (length > 0) {
// Verify the the path exists and that it is a directory.
if (IsFileOrDirectory(szDirectory) != 2) {
return FALSE;
}
}
// Store the directory for when we do an extract.
TSTRTOMBS(g_szExtractToDirectory, szDirectory, countof(g_szExtractToDirectory));
// We always want a wack at the end of our path.
strcat(g_szExtractToDirectory, "\\");
// Add the wack back to the end of the path.
if (fNeedToAddWack) {
_tcscat(szDirectory, TEXT("\\"));
}
return TRUE;
}
//******************************************************************************
//***** Internal functions
//******************************************************************************
static Uz_Globs* InitGlobals(LPCSTR szZipFile)
{
// Create our global structure - pG
CONSTRUCTGLOBALS();
// Bail out if we failed to allocate our Globals structure.
if (!pG) {
return NULL;
}
// Clear our USERFUNCTIONS structure
ZeroMemory(&g_uf, sizeof(g_uf));
// Initialize a global pointer to our USERFUNCTIONS structure that is
// used by WINMAIN.CPP to access it (without using the pG construction).
lpUserFunctions = &g_uf;
// Store a global pointer to our USERFUNCTIONS structure in pG so that
// the generic Info-ZIP code LIST.C and PROCESS.C can access it.
pG->lpUserFunctions = &g_uf;
// Fill in all our callback functions.
pG->message = UzpMessagePrnt2;
pG->input = UzpInput2;
pG->mpause = UzpMorePause;
pG->statreportcb = CheckForAbort2;
pG->lpUserFunctions->replace = UzpReplace;
pG->lpUserFunctions->sound = UzpSound;
pG->lpUserFunctions->SendApplicationMessage = SendAppMsg;
pG->lpUserFunctions->SendApplicationMessage_i32 = NULL;
#if CRYPT
pG->decr_passwd = UzpPassword;
#endif
( run in 1.635 second using v1.01-cache-2.11-cpan-39bf76dae61 )