2006-01-10 12:14:47 +01:00
|
|
|
/*
|
|
|
|
* Unit tests for cabinet.dll extract functions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 James Hawkins
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-01-10 12:14:47 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <windows.h>
|
2006-08-07 06:39:43 +02:00
|
|
|
#include "fci.h"
|
2007-08-21 19:15:39 +02:00
|
|
|
#include "fdi.h"
|
2006-01-10 12:14:47 +01:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
/* make the max size large so there is only one cab file */
|
|
|
|
#define MEDIA_SIZE 999999999
|
|
|
|
#define FOLDER_THRESHOLD 900000
|
|
|
|
|
2008-01-17 00:04:38 +01:00
|
|
|
/* The following definitions were copied from dlls/cabinet/cabinet.h
|
2006-01-10 12:14:47 +01:00
|
|
|
* because they are undocumented in windows.
|
|
|
|
*/
|
|
|
|
|
2007-08-21 19:15:39 +02:00
|
|
|
/* SESSION Operation */
|
2006-01-10 12:14:47 +01:00
|
|
|
#define EXTRACT_FILLFILELIST 0x00000001
|
|
|
|
#define EXTRACT_EXTRACTFILES 0x00000002
|
|
|
|
|
2007-08-21 19:15:39 +02:00
|
|
|
struct FILELIST{
|
|
|
|
LPSTR FileName;
|
|
|
|
struct FILELIST *next;
|
2007-08-27 03:15:41 +02:00
|
|
|
BOOL DoExtract;
|
2006-01-10 12:14:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
2007-08-21 19:15:39 +02:00
|
|
|
INT FileSize;
|
|
|
|
ERF Error;
|
|
|
|
struct FILELIST *FileList;
|
|
|
|
INT FileCount;
|
|
|
|
INT Operation;
|
|
|
|
CHAR Destination[MAX_PATH];
|
|
|
|
CHAR CurrentFile[MAX_PATH];
|
|
|
|
CHAR Reserved[MAX_PATH];
|
|
|
|
struct FILELIST *FilterList;
|
|
|
|
} SESSION;
|
2006-01-10 12:14:47 +01:00
|
|
|
|
|
|
|
/* function pointers */
|
|
|
|
HMODULE hCabinet;
|
2007-08-21 19:15:39 +02:00
|
|
|
static HRESULT (WINAPI *pExtract)(SESSION*, LPCSTR);
|
2006-01-10 12:14:47 +01:00
|
|
|
|
|
|
|
CHAR CURR_DIR[MAX_PATH];
|
|
|
|
|
2006-02-06 13:13:28 +01:00
|
|
|
static void init_function_pointers(void)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
2007-08-14 19:07:45 +02:00
|
|
|
hCabinet = GetModuleHandleA("cabinet.dll");
|
2006-01-10 12:14:47 +01:00
|
|
|
|
2007-08-14 19:07:45 +02:00
|
|
|
pExtract = (void *)GetProcAddress(hCabinet, "Extract");
|
2006-01-10 12:14:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* creates a file with the specified name for tests */
|
|
|
|
static void createTestFile(const CHAR *name)
|
|
|
|
{
|
|
|
|
HANDLE file;
|
|
|
|
DWORD written;
|
|
|
|
|
|
|
|
file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
|
|
|
|
ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
|
|
|
|
WriteFile(file, name, strlen(name), &written, NULL);
|
|
|
|
WriteFile(file, "\n", strlen("\n"), &written, NULL);
|
|
|
|
CloseHandle(file);
|
|
|
|
}
|
|
|
|
|
2006-02-06 13:13:28 +01:00
|
|
|
static void create_test_files(void)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
|
|
|
|
len = lstrlenA(CURR_DIR);
|
|
|
|
|
|
|
|
if(len && (CURR_DIR[len-1] == '\\'))
|
|
|
|
CURR_DIR[len-1] = 0;
|
|
|
|
|
|
|
|
createTestFile("a.txt");
|
|
|
|
createTestFile("b.txt");
|
|
|
|
CreateDirectoryA("testdir", NULL);
|
|
|
|
createTestFile("testdir\\c.txt");
|
|
|
|
createTestFile("testdir\\d.txt");
|
|
|
|
CreateDirectoryA("dest", NULL);
|
|
|
|
}
|
|
|
|
|
2006-02-06 13:13:28 +01:00
|
|
|
static void delete_test_files(void)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
DeleteFileA("a.txt");
|
|
|
|
DeleteFileA("b.txt");
|
|
|
|
DeleteFileA("testdir\\c.txt");
|
|
|
|
DeleteFileA("testdir\\d.txt");
|
|
|
|
RemoveDirectoryA("testdir");
|
|
|
|
|
|
|
|
DeleteFileA("extract.cab");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the FCI callbacks */
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static void * CDECL mem_alloc(ULONG cb)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
return HeapAlloc(GetProcessHeap(), 0, cb);
|
|
|
|
}
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static void CDECL mem_free(void *memory)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, memory);
|
|
|
|
}
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static long CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static int CDECL file_placed(PCCAB pccab, char *pszFile, long cbFile,
|
|
|
|
BOOL fContinuation, void *pv)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
HANDLE handle;
|
|
|
|
DWORD dwAccess = 0;
|
|
|
|
DWORD dwShareMode = 0;
|
|
|
|
DWORD dwCreateDisposition = OPEN_EXISTING;
|
|
|
|
|
|
|
|
dwAccess = GENERIC_READ | GENERIC_WRITE;
|
2006-10-06 11:41:36 +02:00
|
|
|
/* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
|
|
|
|
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
2006-01-10 12:14:47 +01:00
|
|
|
|
|
|
|
if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
|
|
|
|
dwCreateDisposition = OPEN_EXISTING;
|
|
|
|
else
|
|
|
|
dwCreateDisposition = CREATE_NEW;
|
|
|
|
|
|
|
|
handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
|
|
|
|
dwCreateDisposition, 0, NULL);
|
|
|
|
|
|
|
|
ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
|
|
|
|
|
|
|
|
return (INT_PTR)handle;
|
|
|
|
}
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
HANDLE handle = (HANDLE)hf;
|
|
|
|
DWORD dwRead;
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
res = ReadFile(handle, memory, cb, &dwRead, NULL);
|
|
|
|
ok(res, "Failed to ReadFile\n");
|
|
|
|
|
|
|
|
return dwRead;
|
|
|
|
}
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
HANDLE handle = (HANDLE)hf;
|
|
|
|
DWORD dwWritten;
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
res = WriteFile(handle, memory, cb, &dwWritten, NULL);
|
|
|
|
ok(res, "Failed to WriteFile\n");
|
|
|
|
|
|
|
|
return dwWritten;
|
|
|
|
}
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
HANDLE handle = (HANDLE)hf;
|
|
|
|
ok(CloseHandle(handle), "Failed to CloseHandle\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static long CDECL fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
HANDLE handle = (HANDLE)hf;
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
ret = SetFilePointer(handle, dist, NULL, seektype);
|
|
|
|
ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static int CDECL fci_delete(char *pszFile, int *err, void *pv)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
BOOL ret = DeleteFileA(pszFile);
|
|
|
|
ok(ret, "Failed to DeleteFile %s\n", pszFile);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
LPSTR tempname;
|
|
|
|
|
|
|
|
tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
|
|
|
|
GetTempFileNameA(".", "xx", 0, tempname);
|
|
|
|
|
|
|
|
if (tempname && (strlen(tempname) < (unsigned)cbTempName))
|
|
|
|
{
|
|
|
|
lstrcpyA(pszTempName, tempname);
|
|
|
|
HeapFree(GetProcessHeap(), 0, tempname);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, tempname);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-01-03 20:12:39 +01:00
|
|
|
static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
|
|
|
|
USHORT *pattribs, int *err, void *pv)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
BY_HANDLE_FILE_INFORMATION finfo;
|
|
|
|
FILETIME filetime;
|
|
|
|
HANDLE handle;
|
|
|
|
DWORD attrs;
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
|
|
|
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
|
|
|
|
|
|
|
ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
|
|
|
|
|
|
|
|
res = GetFileInformationByHandle(handle, &finfo);
|
|
|
|
ok(res, "Expected GetFileInformationByHandle to succeed\n");
|
|
|
|
|
|
|
|
FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
|
|
|
|
FileTimeToDosDateTime(&filetime, pdate, ptime);
|
|
|
|
|
|
|
|
attrs = GetFileAttributes(pszName);
|
|
|
|
ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
|
|
|
|
|
|
|
|
return (INT_PTR)handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void add_file(HFCI hfci, char *file)
|
|
|
|
{
|
|
|
|
char path[MAX_PATH];
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
lstrcpyA(path, CURR_DIR);
|
|
|
|
lstrcatA(path, "\\");
|
|
|
|
lstrcatA(path, file);
|
|
|
|
|
|
|
|
res = FCIAddFile(hfci, path, file, FALSE, get_next_cabinet, progress,
|
|
|
|
get_open_info, tcompTYPE_MSZIP);
|
|
|
|
ok(res, "Expected FCIAddFile to succeed\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_cab_parameters(PCCAB pCabParams)
|
|
|
|
{
|
|
|
|
ZeroMemory(pCabParams, sizeof(CCAB));
|
|
|
|
|
|
|
|
pCabParams->cb = MEDIA_SIZE;
|
|
|
|
pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
|
|
|
|
pCabParams->setID = 0xbeef;
|
|
|
|
lstrcpyA(pCabParams->szCabPath, CURR_DIR);
|
|
|
|
lstrcatA(pCabParams->szCabPath, "\\");
|
|
|
|
lstrcpyA(pCabParams->szCab, "extract.cab");
|
|
|
|
}
|
|
|
|
|
2006-02-06 13:13:28 +01:00
|
|
|
static void create_cab_file(void)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
|
|
|
CCAB cabParams;
|
|
|
|
HFCI hfci;
|
|
|
|
ERF erf;
|
2006-08-14 20:09:02 +02:00
|
|
|
static CHAR a_txt[] = "a.txt",
|
|
|
|
b_txt[] = "b.txt",
|
|
|
|
testdir_c_txt[] = "testdir\\c.txt",
|
|
|
|
testdir_d_txt[] = "testdir\\d.txt";
|
2006-01-10 12:14:47 +01:00
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
set_cab_parameters(&cabParams);
|
|
|
|
|
|
|
|
hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
|
|
|
|
fci_read, fci_write, fci_close, fci_seek, fci_delete,
|
|
|
|
get_temp_file, &cabParams, NULL);
|
|
|
|
|
|
|
|
ok(hfci != NULL, "Failed to create an FCI context\n");
|
|
|
|
|
2006-08-14 20:09:02 +02:00
|
|
|
add_file(hfci, a_txt);
|
|
|
|
add_file(hfci, b_txt);
|
|
|
|
add_file(hfci, testdir_c_txt);
|
|
|
|
add_file(hfci, testdir_d_txt);
|
2006-01-10 12:14:47 +01:00
|
|
|
|
|
|
|
res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
|
|
|
|
ok(res, "Failed to flush the cabinet\n");
|
|
|
|
|
|
|
|
res = FCIDestroy(hfci);
|
|
|
|
ok(res, "Failed to destroy the cabinet\n");
|
|
|
|
}
|
|
|
|
|
2007-08-27 03:15:41 +02:00
|
|
|
static BOOL check_list(struct FILELIST **node, const char *filename, BOOL do_extract)
|
2006-08-07 06:39:43 +02:00
|
|
|
{
|
2007-08-23 23:42:27 +02:00
|
|
|
if (!*node)
|
|
|
|
return FALSE;
|
2007-08-21 19:15:39 +02:00
|
|
|
|
2007-08-23 23:42:27 +02:00
|
|
|
if (lstrcmpA((*node)->FileName, filename))
|
|
|
|
return FALSE;
|
2006-08-07 06:39:43 +02:00
|
|
|
|
2007-08-27 03:15:41 +02:00
|
|
|
if ((*node)->DoExtract != do_extract)
|
2007-08-23 23:42:27 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*node = (*node)->next;
|
|
|
|
return TRUE;
|
2006-08-07 06:39:43 +02:00
|
|
|
}
|
|
|
|
|
2006-02-06 13:13:28 +01:00
|
|
|
static void test_Extract(void)
|
2006-01-10 12:14:47 +01:00
|
|
|
{
|
2007-08-21 19:15:39 +02:00
|
|
|
SESSION session;
|
2006-01-10 12:14:47 +01:00
|
|
|
HRESULT res;
|
2007-08-23 23:42:27 +02:00
|
|
|
struct FILELIST *node;
|
2006-01-10 12:14:47 +01:00
|
|
|
|
|
|
|
/* native windows crashes if
|
|
|
|
* - invalid parameters are sent in
|
|
|
|
* - you call EXTRACT_EXTRACTFILES without calling
|
|
|
|
* EXTRACT_FILLFILELIST first or at the same time
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* try to extract all files */
|
2007-08-21 19:15:39 +02:00
|
|
|
ZeroMemory(&session, sizeof(SESSION));
|
|
|
|
lstrcpyA(session.Destination, "dest");
|
|
|
|
session.Operation = EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES;
|
|
|
|
res = pExtract(&session, "extract.cab");
|
2007-08-23 23:42:27 +02:00
|
|
|
node = session.FileList;
|
2006-10-05 22:07:06 +02:00
|
|
|
ok(res == S_OK, "Expected S_OK, got %d\n", res);
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(session.Error.erfOper == FDIERROR_NONE,
|
|
|
|
"Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
|
|
|
|
ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
|
|
|
|
ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
|
|
|
|
ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount);
|
|
|
|
ok(session.Operation == (EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES),
|
|
|
|
"Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n", session.Operation);
|
|
|
|
ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
|
|
|
|
ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
|
|
|
|
"Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile);
|
|
|
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
|
|
|
ok(!session.FilterList, "Expected empty filter list\n");
|
2006-01-10 12:14:47 +01:00
|
|
|
ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
|
|
|
|
ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to 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 exist\n");
|
|
|
|
ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
|
2007-08-23 23:42:27 +02:00
|
|
|
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, "b.txt", FALSE), "list entry wrong\n");
|
|
|
|
ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
|
2006-01-10 12:14:47 +01:00
|
|
|
|
|
|
|
/* try fill file list operation */
|
2007-08-21 19:15:39 +02:00
|
|
|
ZeroMemory(&session, sizeof(SESSION));
|
|
|
|
lstrcpyA(session.Destination, "dest");
|
|
|
|
session.Operation = EXTRACT_FILLFILELIST;
|
|
|
|
res = pExtract(&session, "extract.cab");
|
2007-08-23 23:42:27 +02:00
|
|
|
node = session.FileList;
|
2006-10-05 22:07:06 +02:00
|
|
|
ok(res == S_OK, "Expected S_OK, got %d\n", res);
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(session.Error.erfOper == FDIERROR_NONE,
|
|
|
|
"Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
|
|
|
|
ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
|
|
|
|
ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
|
|
|
|
ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount);
|
|
|
|
ok(session.Operation == EXTRACT_FILLFILELIST,
|
|
|
|
"Expected EXTRACT_FILLFILELIST, got %d\n", session.Operation);
|
|
|
|
ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
|
|
|
|
ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
|
|
|
|
"Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile);
|
|
|
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
|
|
|
ok(!session.FilterList, "Expected empty filter list\n");
|
2006-01-10 12:14:47 +01:00
|
|
|
ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
|
|
|
|
ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(check_list(&node, "testdir\\d.txt", TRUE), "list entry wrong\n");
|
|
|
|
ok(check_list(&node, "testdir\\c.txt", TRUE), "list entry wrong\n");
|
|
|
|
ok(check_list(&node, "b.txt", TRUE), "list entry wrong\n");
|
|
|
|
ok(check_list(&node, "a.txt", TRUE), "list entry wrong\n");
|
2006-01-10 12:14:47 +01:00
|
|
|
|
|
|
|
/* try extract files operation once file list is filled */
|
2007-08-21 19:15:39 +02:00
|
|
|
session.Operation = EXTRACT_EXTRACTFILES;
|
|
|
|
res = pExtract(&session, "extract.cab");
|
2007-08-23 23:42:27 +02:00
|
|
|
node = session.FileList;
|
2006-10-05 22:07:06 +02:00
|
|
|
ok(res == S_OK, "Expected S_OK, got %d\n", res);
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(session.Error.erfOper == FDIERROR_NONE,
|
|
|
|
"Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
|
|
|
|
ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
|
|
|
|
ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
|
|
|
|
ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount);
|
|
|
|
ok(session.Operation == EXTRACT_EXTRACTFILES,
|
|
|
|
"Expected EXTRACT_EXTRACTFILES, got %d\n", session.Operation);
|
|
|
|
ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
|
|
|
|
ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
|
|
|
|
"Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile);
|
|
|
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
|
|
|
ok(!session.FilterList, "Expected empty filter list\n");
|
2006-01-10 12:14:47 +01:00
|
|
|
ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
|
|
|
|
ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to 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 exist\n");
|
|
|
|
ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
|
|
|
|
ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
|
2007-08-23 23:42:27 +02:00
|
|
|
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, "b.txt", FALSE), "list entry wrong\n");
|
|
|
|
ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
|
2006-01-10 12:14:47 +01:00
|
|
|
|
|
|
|
/* Extract does not extract files if the dest dir does not exist */
|
2007-08-21 19:15:39 +02:00
|
|
|
res = pExtract(&session, "extract.cab");
|
2007-08-23 23:42:27 +02:00
|
|
|
node = session.FileList;
|
2006-10-05 22:07:06 +02:00
|
|
|
ok(res == S_OK, "Expected S_OK, got %d\n", res);
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(session.Error.erfOper == FDIERROR_NONE,
|
|
|
|
"Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
|
|
|
|
ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
|
|
|
|
ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
|
|
|
|
ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount);
|
|
|
|
ok(session.Operation == EXTRACT_EXTRACTFILES,
|
|
|
|
"Expected EXTRACT_EXTRACTFILES, got %d\n", session.Operation);
|
|
|
|
ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
|
|
|
|
ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
|
|
|
|
"Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile);
|
|
|
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
|
|
|
ok(!session.FilterList, "Expected empty filter list\n");
|
2006-01-10 12:14:47 +01:00
|
|
|
ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
|
2007-08-27 03:15:41 +02:00
|
|
|
ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
|
2006-01-10 12:14:47 +01:00
|
|
|
ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
|
2007-08-27 03:15:41 +02:00
|
|
|
ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
|
2007-08-23 23:42:27 +02:00
|
|
|
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, "b.txt", FALSE), "list entry wrong\n");
|
|
|
|
ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
|
2006-08-07 06:39:43 +02:00
|
|
|
|
2006-01-10 12:14:47 +01:00
|
|
|
/* remove two of the files in the list */
|
2007-08-21 19:15:39 +02:00
|
|
|
session.FileList->next = session.FileList->next->next;
|
|
|
|
session.FileList->next->next = NULL;
|
|
|
|
session.FilterList = NULL;
|
2006-01-10 12:14:47 +01:00
|
|
|
CreateDirectoryA("dest", NULL);
|
2007-08-21 19:15:39 +02:00
|
|
|
res = pExtract(&session, "extract.cab");
|
2007-08-23 23:42:27 +02:00
|
|
|
node = session.FileList;
|
2006-10-05 22:07:06 +02:00
|
|
|
ok(res == S_OK, "Expected S_OK, got %d\n", res);
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(session.Error.erfOper == FDIERROR_NONE,
|
|
|
|
"Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
|
|
|
|
ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
|
|
|
|
ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
|
|
|
|
ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount);
|
|
|
|
ok(session.Operation == EXTRACT_EXTRACTFILES,
|
|
|
|
"Expected EXTRACT_EXTRACTFILES, got %d\n", session.Operation);
|
|
|
|
ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
|
|
|
|
ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
|
|
|
|
"Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile);
|
|
|
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
|
|
|
ok(!session.FilterList, "Expected empty filter list\n");
|
2007-08-27 03:15:41 +02:00
|
|
|
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\\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");
|
2007-08-23 23:42:27 +02:00
|
|
|
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, "b.txt", FALSE), "list entry wrong\n");
|
|
|
|
ok(!check_list(&node, "a.txt", FALSE), "list entry wrong\n");
|
2006-08-07 06:39:43 +02:00
|
|
|
|
2007-08-21 19:15:39 +02:00
|
|
|
session.Operation = EXTRACT_FILLFILELIST;
|
|
|
|
session.FileList = NULL;
|
|
|
|
res = pExtract(&session, "extract.cab");
|
2007-08-23 23:42:27 +02:00
|
|
|
node = session.FileList;
|
2006-10-05 22:07:06 +02:00
|
|
|
ok(res == S_OK, "Expected S_OK, got %d\n", res);
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(session.Error.erfOper == FDIERROR_NONE,
|
|
|
|
"Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
|
|
|
|
ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
|
|
|
|
ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
|
|
|
|
ok(session.FileCount == 8, "Expected 8, got %d\n", session.FileCount);
|
|
|
|
ok(session.Operation == EXTRACT_FILLFILELIST,
|
|
|
|
"Expected EXTRACT_FILLFILELIST, got %d\n", session.Operation);
|
|
|
|
ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
|
|
|
|
ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
|
|
|
|
"Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile);
|
|
|
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
|
|
|
ok(!session.FilterList, "Expected empty filter list\n");
|
2006-08-07 06:39:43 +02:00
|
|
|
ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
|
|
|
|
ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.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");
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(check_list(&node, "testdir\\d.txt", TRUE), "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, "a.txt", FALSE), "list entry wrong\n");
|
2006-08-07 06:39:43 +02:00
|
|
|
|
2007-08-21 19:15:39 +02:00
|
|
|
session.Operation = 0;
|
|
|
|
res = pExtract(&session, "extract.cab");
|
2007-08-23 23:42:27 +02:00
|
|
|
node = session.FileList;
|
2006-10-05 22:07:06 +02:00
|
|
|
ok(res == S_OK, "Expected S_OK, got %d\n", res);
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(session.Error.erfOper == FDIERROR_NONE,
|
|
|
|
"Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
|
|
|
|
ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
|
|
|
|
ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
|
|
|
|
ok(session.FileCount == 8, "Expected 8, got %d\n", session.FileCount);
|
|
|
|
ok(session.Operation == 0, "Expected 0, got %d\n", session.Operation);
|
|
|
|
ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
|
|
|
|
ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
|
|
|
|
"Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile);
|
|
|
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
|
|
|
ok(!session.FilterList, "Expected empty filter list\n");
|
2006-08-07 06:39:43 +02:00
|
|
|
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\\b.txt"), "Expected dest\\b.txt to exist\n");
|
|
|
|
ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(check_list(&node, "testdir\\d.txt", TRUE), "list entry wrong\n");
|
|
|
|
ok(check_list(&node, "testdir\\c.txt", TRUE), "list entry wrong\n");
|
|
|
|
ok(check_list(&node, "b.txt", TRUE), "list entry wrong\n");
|
|
|
|
ok(check_list(&node, "a.txt", TRUE), "list entry wrong\n");
|
2006-08-07 06:39:43 +02:00
|
|
|
|
2007-08-21 19:15:39 +02:00
|
|
|
session.Operation = 0;
|
|
|
|
session.FilterList = session.FileList;
|
|
|
|
res = pExtract(&session, "extract.cab");
|
2007-08-23 23:42:27 +02:00
|
|
|
node = session.FileList;
|
2006-10-05 22:07:06 +02:00
|
|
|
ok(res == S_OK, "Expected S_OK, got %d\n", res);
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(session.Error.erfOper == FDIERROR_NONE,
|
|
|
|
"Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
|
|
|
|
ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
|
|
|
|
ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
|
|
|
|
ok(session.FileCount == 8, "Expected 8, got %d\n", session.FileCount);
|
|
|
|
ok(session.Operation == 0, "Expected 0, got %d\n", session.Operation);
|
|
|
|
ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
|
|
|
|
ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
|
|
|
|
"Expected dest\\testdir\\d.txt, got %s\n", session.CurrentFile);
|
|
|
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
2006-08-07 06:39:43 +02:00
|
|
|
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\\b.txt"), "Expected dest\\b.txt to exist\n");
|
|
|
|
ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
|
2007-08-23 23:42:27 +02:00
|
|
|
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, "b.txt", FALSE), "list entry wrong\n");
|
|
|
|
ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
|
|
|
|
node = session.FilterList;
|
|
|
|
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, "b.txt", FALSE), "list entry wrong\n");
|
|
|
|
ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
|
2007-08-21 19:15:39 +02:00
|
|
|
|
|
|
|
/* cabinet does not exist */
|
|
|
|
ZeroMemory(&session, sizeof(SESSION));
|
|
|
|
lstrcpyA(session.Destination, "dest");
|
|
|
|
session.Operation = EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES;
|
|
|
|
res = pExtract(&session, "nonexistent.cab");
|
2007-08-23 23:42:27 +02:00
|
|
|
node = session.FileList;
|
2007-08-24 00:46:52 +02:00
|
|
|
ok(res == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND),
|
|
|
|
"Expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got %08x\n", res);
|
|
|
|
ok(session.Error.erfOper == FDIERROR_CABINET_NOT_FOUND,
|
|
|
|
"Expected FDIERROR_CABINET_NOT_FOUND, got %d\n", session.Error.erfOper);
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(session.FileSize == 0, "Expected 0, got %d\n", session.FileSize);
|
|
|
|
ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
|
2007-08-23 23:20:52 +02:00
|
|
|
ok(session.Error.fError == TRUE, "Expected TRUE, got %d\n", session.Error.fError);
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(session.FileCount == 0, "Expected 0, got %d\n", session.FileCount);
|
|
|
|
ok(session.Operation == (EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES),
|
|
|
|
"Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n", session.Operation);
|
|
|
|
ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
|
|
|
|
ok(!*session.CurrentFile, "Expected empty string, got %s\n", session.CurrentFile);
|
|
|
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
|
|
|
ok(!session.FilterList, "Expected empty filter list\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\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(!check_list(&node, "testdir\\d.txt", FALSE), "list entry should not exist\n");
|
|
|
|
ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry should not exist\n");
|
|
|
|
ok(!check_list(&node, "b.txt", FALSE), "list entry should not exist\n");
|
|
|
|
ok(!check_list(&node, "a.txt", FALSE), "list entry should not exist\n");
|
2007-08-21 19:15:39 +02:00
|
|
|
|
|
|
|
/* first file exists */
|
|
|
|
createTestFile("dest\\a.txt");
|
|
|
|
SetFileAttributes("dest\\a.txt", FILE_ATTRIBUTE_READONLY);
|
|
|
|
ZeroMemory(&session, sizeof(SESSION));
|
|
|
|
lstrcpyA(session.Destination, "dest");
|
|
|
|
session.Operation = EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES;
|
|
|
|
res = pExtract(&session, "extract.cab");
|
2007-08-23 23:42:27 +02:00
|
|
|
node = session.FileList;
|
2007-08-21 19:15:39 +02:00
|
|
|
todo_wine
|
|
|
|
{
|
2007-10-25 22:19:17 +02:00
|
|
|
ok(res == HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) || res == E_FAIL,
|
|
|
|
"Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) or E_FAIL, got %08x\n", res);
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(session.FileSize == 6, "Expected 6, got %d\n", session.FileSize);
|
|
|
|
ok(session.Error.erfOper == FDIERROR_USER_ABORT,
|
|
|
|
"Expected FDIERROR_USER_ABORT, got %d\n", session.Error.erfOper);
|
|
|
|
ok(session.Error.fError == TRUE, "Expected TRUE, got %d\n", session.Error.fError);
|
|
|
|
ok(session.FileCount == 1, "Expected 1, got %d\n", session.FileCount);
|
|
|
|
ok(!lstrcmpA(session.CurrentFile, "dest\\a.txt"),
|
|
|
|
"Expected dest\\a.txt, got %s\n", session.CurrentFile);
|
|
|
|
}
|
|
|
|
ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
|
|
|
|
ok(session.Operation == (EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES),
|
|
|
|
"Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n", session.Operation);
|
|
|
|
ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
|
|
|
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
|
|
|
ok(!session.FilterList, "Expected empty filter list\n");
|
|
|
|
ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
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\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(!check_list(&node, "testdir\\d.txt", FALSE), "list entry should not exist\n");
|
|
|
|
ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry should not exist\n");
|
|
|
|
ok(!check_list(&node, "b.txt", FALSE), "list entry should not exist\n");
|
2007-08-21 19:15:39 +02:00
|
|
|
}
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(!check_list(&node, "a.txt", FALSE), "list entry should not exist\n");
|
2007-08-21 19:15:39 +02:00
|
|
|
|
|
|
|
SetFileAttributesA("dest\\a.txt", FILE_ATTRIBUTE_NORMAL);
|
|
|
|
DeleteFileA("dest\\a.txt");
|
|
|
|
|
|
|
|
/* third file exists */
|
|
|
|
createTestFile("dest\\testdir\\c.txt");
|
|
|
|
SetFileAttributes("dest\\testdir\\c.txt", FILE_ATTRIBUTE_READONLY);
|
|
|
|
ZeroMemory(&session, sizeof(SESSION));
|
|
|
|
lstrcpyA(session.Destination, "dest");
|
|
|
|
session.Operation = EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES;
|
|
|
|
res = pExtract(&session, "extract.cab");
|
|
|
|
todo_wine
|
|
|
|
{
|
2007-10-25 22:19:17 +02:00
|
|
|
ok(res == HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) || res == E_FAIL,
|
|
|
|
"Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) or E_FAIL, got %08x\n", res);
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(session.FileSize == 26, "Expected 26, got %d\n", session.FileSize);
|
|
|
|
ok(session.Error.erfOper == FDIERROR_USER_ABORT,
|
|
|
|
"Expected FDIERROR_USER_ABORT, got %d\n", session.Error.erfOper);
|
|
|
|
ok(session.Error.fError == TRUE, "Expected TRUE, got %d\n", session.Error.fError);
|
|
|
|
ok(session.FileCount == 3, "Expected 3, got %d\n", session.FileCount);
|
|
|
|
ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\c.txt"),
|
|
|
|
"Expected dest\\c.txt, got %s\n", session.CurrentFile);
|
|
|
|
}
|
|
|
|
ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
|
|
|
|
ok(session.Operation == (EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES),
|
|
|
|
"Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n", session.Operation);
|
|
|
|
ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
|
|
|
|
ok(!*session.Reserved, "Expected empty string, got %s\n", session.Reserved);
|
|
|
|
ok(!session.FilterList, "Expected empty filter list\n");
|
|
|
|
ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
|
|
|
|
ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
|
|
|
|
ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
|
|
|
|
}
|
2007-08-23 23:42:27 +02:00
|
|
|
ok(!check_list(&node, "testdir\\d.txt", FALSE), "list entry should not exist\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, "a.txt", TRUE), "list entry wrong\n");
|
2007-08-21 19:15:39 +02:00
|
|
|
|
|
|
|
SetFileAttributesA("dest\\testdir\\c.txt", FILE_ATTRIBUTE_NORMAL);
|
|
|
|
DeleteFileA("dest\\testdir\\c.txt");
|
2006-08-07 06:39:43 +02:00
|
|
|
|
2006-01-10 12:14:47 +01:00
|
|
|
ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
|
2007-08-21 19:15:39 +02:00
|
|
|
ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
|
2006-01-10 12:14:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(extract)
|
|
|
|
{
|
|
|
|
init_function_pointers();
|
|
|
|
create_test_files();
|
|
|
|
create_cab_file();
|
|
|
|
|
|
|
|
test_Extract();
|
|
|
|
|
|
|
|
delete_test_files();
|
|
|
|
}
|