cabinet: Don't extract a file if DoExtract is FALSE.
This commit is contained in:
parent
8d29abb08d
commit
a72e182010
|
@ -523,7 +523,7 @@ HRESULT WINAPI DelNodeRunDLL32W(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT
|
||||||
struct FILELIST{
|
struct FILELIST{
|
||||||
LPSTR FileName;
|
LPSTR FileName;
|
||||||
struct FILELIST *next;
|
struct FILELIST *next;
|
||||||
BOOL Extracted;
|
BOOL DoExtract;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -621,14 +621,12 @@ static BOOL file_in_list(LPCSTR szFile, LPCSTR szFileList)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* removes nodes from the linked list that aren't specified in szFileList
|
|
||||||
* returns the number of files that are in both the linked list and szFileList
|
/* returns the number of files that are in both the linked list and szFileList */
|
||||||
*/
|
|
||||||
static DWORD fill_file_list(SESSION *session, LPCSTR szCabName, LPCSTR szFileList)
|
static DWORD fill_file_list(SESSION *session, LPCSTR szCabName, LPCSTR szFileList)
|
||||||
{
|
{
|
||||||
DWORD dwNumFound = 0;
|
DWORD dwNumFound = 0;
|
||||||
struct FILELIST *pNode;
|
struct FILELIST *pNode;
|
||||||
struct FILELIST *prev = NULL;
|
|
||||||
|
|
||||||
session->Operation |= EXTRACT_FILLFILELIST;
|
session->Operation |= EXTRACT_FILLFILELIST;
|
||||||
if (pExtract(session, szCabName))
|
if (pExtract(session, szCabName))
|
||||||
|
@ -640,24 +638,12 @@ static DWORD fill_file_list(SESSION *session, LPCSTR szCabName, LPCSTR szFileLis
|
||||||
pNode = session->FileList;
|
pNode = session->FileList;
|
||||||
while (pNode)
|
while (pNode)
|
||||||
{
|
{
|
||||||
if (file_in_list(pNode->FileName, szFileList))
|
if (!file_in_list(pNode->FileName, szFileList))
|
||||||
{
|
pNode->DoExtract = FALSE;
|
||||||
prev = pNode;
|
|
||||||
pNode = pNode->next;
|
|
||||||
dwNumFound++;
|
|
||||||
}
|
|
||||||
else if (prev)
|
|
||||||
{
|
|
||||||
prev->next = pNode->next;
|
|
||||||
free_file_node(pNode);
|
|
||||||
pNode = prev->next;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
dwNumFound++;
|
||||||
session->FileList = pNode->next;
|
|
||||||
free_file_node(pNode);
|
pNode = pNode->next;
|
||||||
pNode = session->FileList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
session->Operation &= ~EXTRACT_FILLFILELIST;
|
session->Operation &= ~EXTRACT_FILLFILELIST;
|
||||||
|
|
|
@ -638,7 +638,7 @@ static const cab_UWORD Zipmask[17] = {
|
||||||
struct FILELIST{
|
struct FILELIST{
|
||||||
LPSTR FileName;
|
LPSTR FileName;
|
||||||
struct FILELIST *next;
|
struct FILELIST *next;
|
||||||
BOOL Extracted;
|
BOOL DoExtract;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -157,7 +157,7 @@ static long fdi_seek(INT_PTR hf, long dist, int seektype)
|
||||||
static void fill_file_node(struct FILELIST *pNode, LPCSTR szFilename)
|
static void fill_file_node(struct FILELIST *pNode, LPCSTR szFilename)
|
||||||
{
|
{
|
||||||
pNode->next = NULL;
|
pNode->next = NULL;
|
||||||
pNode->Extracted = FALSE;
|
pNode->DoExtract = 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);
|
||||||
|
@ -188,7 +188,7 @@ static INT_PTR fdi_notify_extract(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf
|
||||||
{
|
{
|
||||||
case fdintCOPY_FILE:
|
case fdintCOPY_FILE:
|
||||||
{
|
{
|
||||||
struct FILELIST *fileList, *node;
|
struct FILELIST *fileList, *node = NULL;
|
||||||
SESSION *pDestination = pfdin->pv;
|
SESSION *pDestination = pfdin->pv;
|
||||||
LPSTR szFullPath, szDirectory;
|
LPSTR szFullPath, szDirectory;
|
||||||
HANDLE hFile = 0;
|
HANDLE hFile = 0;
|
||||||
|
@ -215,7 +215,7 @@ static INT_PTR fdi_notify_extract(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf
|
||||||
sizeof(struct FILELIST));
|
sizeof(struct FILELIST));
|
||||||
|
|
||||||
fill_file_node(fileList, pfdin->psz1);
|
fill_file_node(fileList, pfdin->psz1);
|
||||||
fileList->Extracted = TRUE;
|
fileList->DoExtract = TRUE;
|
||||||
fileList->next = pDestination->FileList;
|
fileList->next = pDestination->FileList;
|
||||||
pDestination->FileList = fileList;
|
pDestination->FileList = fileList;
|
||||||
lstrcpyA(pDestination->CurrentFile, szFullPath);
|
lstrcpyA(pDestination->CurrentFile, szFullPath);
|
||||||
|
@ -225,8 +225,10 @@ static INT_PTR fdi_notify_extract(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf
|
||||||
if ((pDestination->Operation & EXTRACT_EXTRACTFILES) ||
|
if ((pDestination->Operation & EXTRACT_EXTRACTFILES) ||
|
||||||
file_in_list(pDestination->FilterList, pfdin->psz1, NULL))
|
file_in_list(pDestination->FilterList, pfdin->psz1, NULL))
|
||||||
{
|
{
|
||||||
/* skip this file if it is not in the file list */
|
/* find the file node */
|
||||||
if (!file_in_list(pDestination->FileList, pfdin->psz1, &node))
|
file_in_list(pDestination->FileList, pfdin->psz1, &node);
|
||||||
|
|
||||||
|
if (node && !node->DoExtract)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* create the destination directory if it doesn't exist */
|
/* create the destination directory if it doesn't exist */
|
||||||
|
@ -238,8 +240,8 @@ static INT_PTR fdi_notify_extract(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf
|
||||||
|
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
hFile = 0;
|
hFile = 0;
|
||||||
else
|
else if (node)
|
||||||
node->Extracted = FALSE;
|
node->DoExtract = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, szFullPath);
|
HeapFree(GetProcessHeap(), 0, szFullPath);
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
struct FILELIST{
|
struct FILELIST{
|
||||||
LPSTR FileName;
|
LPSTR FileName;
|
||||||
struct FILELIST *next;
|
struct FILELIST *next;
|
||||||
BOOL Extracted;
|
BOOL DoExtract;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -314,7 +314,7 @@ static void create_cab_file(void)
|
||||||
ok(res, "Failed to destroy the cabinet\n");
|
ok(res, "Failed to destroy the cabinet\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL check_list(struct FILELIST **node, const char *filename, BOOL extracted)
|
static BOOL check_list(struct FILELIST **node, const char *filename, BOOL do_extract)
|
||||||
{
|
{
|
||||||
if (!*node)
|
if (!*node)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -322,7 +322,7 @@ static BOOL check_list(struct FILELIST **node, const char *filename, BOOL extrac
|
||||||
if (lstrcmpA((*node)->FileName, filename))
|
if (lstrcmpA((*node)->FileName, filename))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if ((*node)->Extracted != extracted)
|
if ((*node)->DoExtract != do_extract)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
*node = (*node)->next;
|
*node = (*node)->next;
|
||||||
|
@ -445,7 +445,9 @@ static void test_Extract(void)
|
||||||
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
||||||
ok(!session.FilterList, "Expected empty filter list\n");
|
ok(!session.FilterList, "Expected empty filter list\n");
|
||||||
ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
|
ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
|
||||||
|
ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
|
||||||
ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
|
ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
|
||||||
|
ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
|
||||||
ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n");
|
ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n");
|
||||||
ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
|
ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
|
||||||
ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
|
ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
|
||||||
|
@ -472,13 +474,10 @@ static void test_Extract(void)
|
||||||
"Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile);
|
"Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile);
|
||||||
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
||||||
ok(!session.FilterList, "Expected empty filter list\n");
|
ok(!session.FilterList, "Expected empty filter list\n");
|
||||||
todo_wine
|
ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
|
||||||
{
|
ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
|
||||||
ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
|
ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
|
||||||
ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
|
ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
|
||||||
ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
|
|
||||||
ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
|
|
||||||
}
|
|
||||||
ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n");
|
ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n");
|
||||||
ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
|
ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
|
||||||
ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
|
ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
|
||||||
|
|
Loading…
Reference in New Issue