Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/wince/intrface.cpp view on Meta::CPAN
/*
Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2009-Jan-02 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
//******************************************************************************
//
// File: INTRFACE.CPP
//
// Description: This module acts as the interface between the Info-ZIP code and
// our Windows code in WINMAIN.CPP. We expose the needed
// functions to query a file list, test file(s), extract file(s),
// and display a zip file comment. The windows code is never
// bothered with understanding the Globals structure "Uz_Globs".
//
// This module also catches all the callbacks from the Info-ZIP
// code, cleans up the data provided in the callback, and then
// forwards the information to the appropriate function in the
// windows code. These callbacks include status messages, file
// lists, comments, password prompt, and file overwrite prompts.
//
// Finally, this module implements the few functions that the
// Info-ZIP code expects the port to implement. These functions are
// OS dependent and are mostly related to validating file names and
// directories, and setting file attributes and dates of saved files.
//
// Copyright: All the source files for Pocket UnZip, except for components
// written by the Info-ZIP group, are copyrighted 1997 by Steve P.
// Miller. As of June 1999, Steve P. Miller has agreed to apply
// the Info-ZIP License (see citation on top of this module)
// to his work. See the contents of this License for terms
// and conditon of using the product "Pocket UnZip".
//
// Disclaimer: All project files are provided "as is" with no guarantee of
// their correctness. The authors are not liable for any outcome
// that is the result of using this source. The source for Pocket
// UnZip has been placed in the public domain to help provide an
// understanding of its implementation. You are hereby granted
// full permission to use this source in any way you wish, except
// to alter Pocket UnZip itself. For comments, suggestions, and
// bug reports, please write to stevemil@pobox.com or the Info-ZIP
// mailing list Zip-Bugs@lists.wku.edu.
//
// Functions: DoListFiles
// DoExtractOrTestFiles
// DoGetComment
// SetExtractToDirectory
// InitGlobals
// FreeGlobals
// ExtractOrTestFilesThread
// IsFileOrDirectory
// SmartCreateDirectory
// CheckForAbort2
// SetCurrentFile
// UzpMessagePrnt2
// UzpInput2
// UzpMorePause
// UzpPassword
// UzpReplace
// UzpSound
// SendAppMsg
// win_fprintf
// test_NT
// utimeToFileTime
// GetFileTimes
// IsOldFileSystem
// SetFileSize
// close_outfile
// do_wild
// mapattr
// mapname
// checkdir
// match
// iswild
// conv_to_rule
// GetPlatformLocalTimezone
// wide_to_local_string
//
//
unzip-6.0/wince/intrface.cpp view on Meta::CPAN
extern "C" {
#define __INTRFACE_CPP__
#define UNZIP_INTERNAL
#include "unzip.h"
#include "crypt.h" // Needed to pick up CRYPT define
#include <commctrl.h>
#include "intrface.h"
#include "winmain.h"
#ifndef _WIN32_WCE
#include <process.h> // _beginthreadex() and _endthreadex()
#endif
}
#include <tchar.h> // Must be outside of extern "C" block
#ifdef POCKET_UNZIP
//******************************************************************************
//***** "Local" Global Variables
//******************************************************************************
static USERFUNCTIONS g_uf;
static EXTRACT_INFO *g_pExtractInfo = NULL;
static FILE_NODE *g_pFileLast = NULL;
static CHAR g_szExtractToDirectory[_MAX_PATH];
static BOOL g_fOutOfMemory;
//******************************************************************************
//***** Local Function Prototypes
//******************************************************************************
// Internal functions of the GUI interface.
static Uz_Globs* InitGlobals(LPCSTR szZipFile);
static void FreeGlobals(Uz_Globs *pG);
#ifdef _WIN32_WCE
static DWORD WINAPI ExtractOrTestFilesThread(LPVOID lpv);
#else
static unsigned __stdcall ExtractOrTestFilesThread(void *lpv);
#endif
static void SetCurrentFile(__GPRO);
#endif // POCKET_UNZIP
// Internal helper functions for the UnZip core.
static int IsFileOrDirectory(LPCTSTR szPath);
static BOOL SmartCreateDirectory(__GPRO__ LPCSTR szDirectory, BOOL *pNewDir);
static void utimeToFileTime(time_t ut, FILETIME *pft, BOOL fOldFileSystem);
static int GetFileTimes(Uz_Globs *pG, FILETIME *pftCreated,
FILETIME *pftAccessed, FILETIME *pftModified);
// Check for FAT, VFAT, HPFS, etc.
static BOOL IsOldFileSystem(char *szPath);
#ifdef POCKET_UNZIP
extern "C" {
// Local variants of callbacks from Info-ZIP code.
// (These functions are not referenced by name outside this source module.)
int UZ_EXP UzpMessagePrnt2(zvoid *pG, uch *buffer, ulg size, int flag);
int UZ_EXP UzpInput2(zvoid *pG, uch *buffer, int *size, int flag);
int UZ_EXP CheckForAbort2(zvoid *pG, int fnflag, ZCONST char *zfn,
ZCONST char *efn, ZCONST zvoid *details);
int WINAPI UzpReplace(LPSTR szFile, unsigned nbufsiz);
void WINAPI UzpSound(void);
#ifdef Z_UINT8_DEFINED
void WINAPI SendAppMsg(z_uint8 uzSize, z_uint8 uzCompressedSize,
#else
void WINAPI SendAppMsg(ulg uzSize, ulg uzCompressedSize,
#endif
unsigned ratio,
unsigned month, unsigned day, unsigned year,
unsigned hour, unsigned minute, char uppercase,
LPCSTR szPath, LPCSTR szMethod, ulg dwCRC,
char chCrypt);
} // extern "C"
//******************************************************************************
//***** Our exposed interface functions to the Info-ZIP core
//******************************************************************************
int DoListFiles(LPCSTR szZipFile) {
int result;
// Create our Globals struct and fill it in whith some default values.
Uz_Globs *pG = InitGlobals(szZipFile);
if (!pG) {
return PK_MEM;
}
pG->UzO.vflag = 1; // verbosely: list directory (for WIN32 it is 0 or 1)
pG->process_all_files = TRUE; // improves speed
g_pFileLast = NULL;
g_fOutOfMemory = FALSE;
// 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 file information in a
// callback to SendAppMsg().
result = process_zipfiles(pG);
// Make sure we didn't run out of memory in the process.
if (g_fOutOfMemory) {
result = PK_MEM;
}
} __except(EXCEPTION_EXECUTE_HANDLER) {
// Catch any exception here.
DebugOut(TEXT("Exception 0x%08X occurred in DoListFiles()"),
GetExceptionCode());
( run in 1.626 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )