Commit 832e3069 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

cabinet: Formalize the SESSION struct.

parent d13541f8
...@@ -631,29 +631,27 @@ static const cab_UWORD Zipmask[17] = { ...@@ -631,29 +631,27 @@ static const cab_UWORD Zipmask[17] = {
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff \ 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff \
} }
/* EXTRACTdest flags */ /* SESSION Operation */
#define EXTRACT_FILLFILELIST 0x00000001 #define EXTRACT_FILLFILELIST 0x00000001
#define EXTRACT_EXTRACTFILES 0x00000002 #define EXTRACT_EXTRACTFILES 0x00000002
struct ExtractFileList { struct FILELIST{
LPSTR filename; LPSTR FileName;
struct ExtractFileList *next; struct FILELIST *next;
BOOL flag; BOOL Extracted;
} ; };
/* the first parameter of the function extract */
typedef struct { typedef struct {
long result1; /* 0x000 */ INT FileSize;
long unknown1[3]; /* 0x004 */ ERF Error;
struct ExtractFileList *filelist; /* 0x010 */ struct FILELIST *FileList;
long filecount; /* 0x014 */ INT FileCount;
DWORD flags; /* 0x018 */ INT Operation;
char directory[MAX_PATH]; /* 0x01c */ CHAR Destination[MAX_PATH];
char lastfile[MAX_PATH]; /* 0x120 */ CHAR CurrentFile[MAX_PATH];
char unknown2[MAX_PATH]; /* 0x224 */ CHAR Reserved[MAX_PATH];
struct ExtractFileList *filterlist; /* 0x328 */ struct FILELIST *FilterList;
} EXTRACTdest; } SESSION;
/* from fdi.c */ /* from fdi.c */
void QTMupdatemodel(struct QTMmodel *model, int sym); void QTMupdatemodel(struct QTMmodel *model, int sym);
......
...@@ -154,20 +154,20 @@ static long fdi_seek(INT_PTR hf, long dist, int seektype) ...@@ -154,20 +154,20 @@ static long fdi_seek(INT_PTR hf, long dist, int seektype)
return SetFilePointer(handle, dist, NULL, seektype); return SetFilePointer(handle, dist, NULL, seektype);
} }
static void fill_file_node(struct ExtractFileList *pNode, LPCSTR szFilename) static void fill_file_node(struct FILELIST *pNode, LPCSTR szFilename)
{ {
pNode->next = NULL; pNode->next = NULL;
pNode->flag = FALSE; pNode->Extracted = FALSE;
pNode->filename = HeapAlloc(GetProcessHeap(), 0, strlen(szFilename) + 1); pNode->FileName = HeapAlloc(GetProcessHeap(), 0, strlen(szFilename) + 1);
lstrcpyA(pNode->filename, szFilename); lstrcpyA(pNode->FileName, szFilename);
} }
static BOOL file_in_list(const struct ExtractFileList *pNode, LPCSTR szFilename) static BOOL file_in_list(const struct FILELIST *pNode, LPCSTR szFilename)
{ {
while (pNode) while (pNode)
{ {
if (!lstrcmpiA(pNode->filename, szFilename)) if (!lstrcmpiA(pNode->FileName, szFilename))
return TRUE; return TRUE;
pNode = pNode->next; pNode = pNode->next;
...@@ -182,17 +182,17 @@ static INT_PTR fdi_notify_extract(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf ...@@ -182,17 +182,17 @@ static INT_PTR fdi_notify_extract(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf
{ {
case fdintCOPY_FILE: case fdintCOPY_FILE:
{ {
struct ExtractFileList **fileList; struct FILELIST **fileList;
EXTRACTdest *pDestination = pfdin->pv; SESSION *pDestination = pfdin->pv;
LPSTR szFullPath, szDirectory; LPSTR szFullPath, szDirectory;
HANDLE hFile = 0; HANDLE hFile = 0;
DWORD dwSize; DWORD dwSize;
dwSize = lstrlenA(pDestination->directory) + dwSize = lstrlenA(pDestination->Destination) +
lstrlenA("\\") + lstrlenA(pfdin->psz1) + 1; lstrlenA("\\") + lstrlenA(pfdin->psz1) + 1;
szFullPath = HeapAlloc(GetProcessHeap(), 0, dwSize); szFullPath = HeapAlloc(GetProcessHeap(), 0, dwSize);
lstrcpyA(szFullPath, pDestination->directory); lstrcpyA(szFullPath, pDestination->Destination);
lstrcatA(szFullPath, "\\"); lstrcatA(szFullPath, "\\");
lstrcatA(szFullPath, pfdin->psz1); lstrcatA(szFullPath, pfdin->psz1);
...@@ -201,26 +201,26 @@ static INT_PTR fdi_notify_extract(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf ...@@ -201,26 +201,26 @@ static INT_PTR fdi_notify_extract(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf
szDirectory = HeapAlloc(GetProcessHeap(), 0, dwSize); szDirectory = HeapAlloc(GetProcessHeap(), 0, dwSize);
lstrcpynA(szDirectory, szFullPath, dwSize); lstrcpynA(szDirectory, szFullPath, dwSize);
if (pDestination->flags & EXTRACT_FILLFILELIST) if (pDestination->Operation & EXTRACT_FILLFILELIST)
{ {
fileList = &pDestination->filelist; fileList = &pDestination->FileList;
while (*fileList) while (*fileList)
fileList = &((*fileList)->next); fileList = &((*fileList)->next);
*fileList = HeapAlloc(GetProcessHeap(), 0, *fileList = HeapAlloc(GetProcessHeap(), 0,
sizeof(struct ExtractFileList)); sizeof(struct FILELIST));
fill_file_node(*fileList, pfdin->psz1); fill_file_node(*fileList, pfdin->psz1);
lstrcpyA(pDestination->lastfile, szFullPath); lstrcpyA(pDestination->CurrentFile, szFullPath);
pDestination->filecount++; pDestination->FileCount++;
} }
if ((pDestination->flags & EXTRACT_EXTRACTFILES) || if ((pDestination->Operation & EXTRACT_EXTRACTFILES) ||
file_in_list(pDestination->filterlist, pfdin->psz1)) file_in_list(pDestination->FilterList, pfdin->psz1))
{ {
/* skip this file if it is not in the file list */ /* skip this file if it is not in the file list */
if (!file_in_list(pDestination->filelist, pfdin->psz1)) if (!file_in_list(pDestination->FileList, pfdin->psz1))
return 0; return 0;
/* create the destination directory if it doesn't exist */ /* create the destination directory if it doesn't exist */
...@@ -281,25 +281,28 @@ static INT_PTR fdi_notify_extract(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf ...@@ -281,25 +281,28 @@ static INT_PTR fdi_notify_extract(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf
* NOTES * NOTES
* The following members of the dest struct control the operation * The following members of the dest struct control the operation
* of Extract: * of Extract:
* filelist [I] A linked list of filenames. Extract only extracts * FileSize [O] The size of all files extracted up to CurrentFile.
* files from the cabinet that are in this list. * Error [O] The error in case the extract operation fails.
* filecount [O] Contains the number of files in filelist on * FileList [I] A linked list of filenames. Extract only extracts
* completion. * files from the cabinet that are in this list.
* flags [I] See Operation. * FileCount [O] Contains the number of files in FileList on
* directory [I] The destination directory. * completion.
* lastfile [O] The last file extracted. * Operation [I] See Operation.
* Destination [I] The destination directory.
* CurrentFile [O] The last file extracted.
* FilterList [I] A linked list of files that should not be extracted.
* *
* Operation * Operation
* If flags contains EXTRACT_FILLFILELIST, then filelist will be * If Operation contains EXTRACT_FILLFILELIST, then FileList will be
* filled with all the files in the cabinet. If flags contains * filled with all the files in the cabinet. If Operation contains
* EXTRACT_EXTRACTFILES, then only the files in the filelist will * EXTRACT_EXTRACTFILES, then only the files in the FileList will
* be extracted from the cabinet. EXTRACT_FILLFILELIST can be called * be extracted from the cabinet. EXTRACT_FILLFILELIST can be called
* by itself, but EXTRACT_EXTRACTFILES must have a valid filelist * by itself, but EXTRACT_EXTRACTFILES must have a valid FileList
* in order to succeed. If flags contains both EXTRACT_FILLFILELIST * in order to succeed. If Operation contains both EXTRACT_FILLFILELIST
* and EXTRACT_EXTRACTFILES, then all the files in the cabinet * and EXTRACT_EXTRACTFILES, then all the files in the cabinet
* will be extracted. * will be extracted.
*/ */
HRESULT WINAPI Extract(EXTRACTdest *dest, LPCSTR szCabName) HRESULT WINAPI Extract(SESSION *dest, LPCSTR szCabName)
{ {
HRESULT res = S_OK; HRESULT res = S_OK;
HFDI hfdi; HFDI hfdi;
...@@ -321,7 +324,7 @@ HRESULT WINAPI Extract(EXTRACTdest *dest, LPCSTR szCabName) ...@@ -321,7 +324,7 @@ HRESULT WINAPI Extract(EXTRACTdest *dest, LPCSTR szCabName)
if (!hfdi) if (!hfdi)
return E_FAIL; return E_FAIL;
if (GetFileAttributesA(dest->directory) == INVALID_FILE_ATTRIBUTES) if (GetFileAttributesA(dest->Destination) == INVALID_FILE_ATTRIBUTES)
return S_OK; return S_OK;
/* split the cabinet name into path + name */ /* split the cabinet name into path + name */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment