Autosyncing with Wine HEAD

svn path=/trunk/; revision=30858
This commit is contained in:
The Wine Synchronizer 2007-11-29 09:56:40 +00:00
parent e8360ce5fe
commit 255abc607a
5 changed files with 187 additions and 172 deletions

View file

@ -33,6 +33,23 @@
#define _S_IWRITE 0x0080 #define _S_IWRITE 0x0080
#define _S_IREAD 0x0100 #define _S_IREAD 0x0100
/* from msvcrt/fcntl.h */
#define _O_RDONLY 0
#define _O_WRONLY 1
#define _O_RDWR 2
#define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR)
#define _O_APPEND 0x0008
#define _O_RANDOM 0x0010
#define _O_SEQUENTIAL 0x0020
#define _O_TEMPORARY 0x0040
#define _O_NOINHERIT 0x0080
#define _O_CREAT 0x0100
#define _O_TRUNC 0x0200
#define _O_EXCL 0x0400
#define _O_SHORT_LIVED 0x1000
#define _O_TEXT 0x4000
#define _O_BINARY 0x8000
#define CAB_SPLITMAX (10) #define CAB_SPLITMAX (10)
#define CAB_SEARCH_SIZE (32*1024) #define CAB_SEARCH_SIZE (32*1024)
@ -614,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 DoExtract;
} ; };
/* 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);

View file

@ -1,13 +1,12 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="cabinet" type="win32dll" entrypoint="0" baseaddress="${BASEADDRESS_CABINET}" installbase="system32" installname="cabinet.dll" allowwarnings="true"> <module name="cabinet" type="win32dll" entrypoint="0" baseaddress="${BASEADDRESS_CABINET}" installbase="system32" installname="cabinet.dll" allowwarnings="true">
<importlibrary definition="cabinet.spec.def" /> <importlibrary definition="cabinet.spec.def" />
<include base="cabinet">.</include> <include base="cabinet">.</include>
<include base="ReactOS">include/reactos/wine</include> <include base="ReactOS">include/reactos/wine</include>
<define name="__REACTOS__" />
<define name="__WINESRC__" /> <define name="__WINESRC__" />
<define name="__USE_W32API" /> <define name="WINVER">0x600</define>
<define name="_WIN32_IE">0x600</define> <define name="_WIN32_WINNT">0x600</define>
<define name="_WIN32_WINNT">0x501</define>
<define name="WINVER">0x501</define>
<library>wine</library> <library>wine</library>
<library>kernel32</library> <library>kernel32</library>
<library>ntdll</library> <library>ntdll</library>

View file

@ -37,13 +37,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(cabinet); WINE_DEFAULT_DEBUG_CHANNEL(cabinet);
/* the following defintions are copied from msvcrt/fcntl.h */
#define _O_RDONLY 0
#define _O_WRONLY 1
#define _O_RDWR 2
#define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR)
/*********************************************************************** /***********************************************************************
* DllGetVersion (CABINET.2) * DllGetVersion (CABINET.2)
@ -91,7 +84,7 @@ static INT_PTR fdi_open(char *pszFile, int oflag, int pmode)
HANDLE handle; HANDLE handle;
DWORD dwAccess = 0; DWORD dwAccess = 0;
DWORD dwShareMode = 0; DWORD dwShareMode = 0;
DWORD dwCreateDisposition = OPEN_EXISTING; DWORD dwCreateDisposition;
switch (oflag & _O_ACCMODE) switch (oflag & _O_ACCMODE)
{ {
@ -109,10 +102,17 @@ static INT_PTR fdi_open(char *pszFile, int oflag, int pmode)
break; break;
} }
if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES) if (oflag & _O_CREAT)
dwCreateDisposition = OPEN_EXISTING; {
dwCreateDisposition = OPEN_ALWAYS;
if (oflag & _O_EXCL) dwCreateDisposition = CREATE_NEW;
else if (oflag & _O_TRUNC) dwCreateDisposition = CREATE_ALWAYS;
}
else else
dwCreateDisposition = CREATE_NEW; {
dwCreateDisposition = OPEN_EXISTING;
if (oflag & _O_TRUNC) dwCreateDisposition = TRUNCATE_EXISTING;
}
handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL, handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
dwCreateDisposition, 0, NULL); dwCreateDisposition, 0, NULL);
@ -154,21 +154,27 @@ 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->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);
} }
static BOOL file_in_list(const struct ExtractFileList *pNode, LPCSTR szFilename) static BOOL file_in_list(struct FILELIST *pNode, LPCSTR szFilename,
struct FILELIST **pOut)
{ {
while (pNode) while (pNode)
{ {
if (!lstrcmpiA(pNode->filename, szFilename)) if (!lstrcmpiA(pNode->FileName, szFilename))
{
if (pOut)
*pOut = pNode;
return TRUE; return TRUE;
}
pNode = pNode->next; pNode = pNode->next;
} }
@ -182,17 +188,17 @@ static INT_PTR fdi_notify_extract(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf
{ {
case fdintCOPY_FILE: case fdintCOPY_FILE:
{ {
struct ExtractFileList **fileList; struct FILELIST *fileList, *node = NULL;
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 +207,28 @@ 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) pDestination->FileSize += pfdin->cb;
if (pDestination->Operation & EXTRACT_FILLFILELIST)
{ {
fileList = &pDestination->filelist; fileList = HeapAlloc(GetProcessHeap(), 0,
sizeof(struct FILELIST));
while (*fileList) fill_file_node(fileList, pfdin->psz1);
fileList = &((*fileList)->next); fileList->DoExtract = TRUE;
fileList->next = pDestination->FileList;
*fileList = HeapAlloc(GetProcessHeap(), 0, pDestination->FileList = fileList;
sizeof(struct ExtractFileList)); lstrcpyA(pDestination->CurrentFile, szFullPath);
pDestination->FileCount++;
fill_file_node(*fileList, pfdin->psz1);
lstrcpyA(pDestination->lastfile, szFullPath);
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, NULL))
{ {
/* skip this file if it is not in the file list */ /* find the file node */
if (!file_in_list(pDestination->filelist, pfdin->psz1)) 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 */
@ -232,6 +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 if (node)
node->DoExtract = FALSE;
} }
HeapFree(GetProcessHeap(), 0, szFullPath); HeapFree(GetProcessHeap(), 0, szFullPath);
@ -281,29 +291,31 @@ 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;
ERF erf;
char *str, *path, *name; char *str, *path, *name;
TRACE("(%p, %s)\n", dest, szCabName); TRACE("(%p, %s)\n", dest, szCabName);
@ -316,12 +328,12 @@ HRESULT WINAPI Extract(EXTRACTdest *dest, LPCSTR szCabName)
fdi_close, fdi_close,
fdi_seek, fdi_seek,
cpuUNKNOWN, cpuUNKNOWN,
&erf); &dest->Error);
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 */
@ -343,9 +355,11 @@ HRESULT WINAPI Extract(EXTRACTdest *dest, LPCSTR szCabName)
path = NULL; path = NULL;
} }
dest->FileSize = 0;
if (!FDICopy(hfdi, name, path, 0, if (!FDICopy(hfdi, name, path, 0,
fdi_notify_extract, NULL, dest)) fdi_notify_extract, NULL, dest))
res = E_FAIL; res = HRESULT_FROM_WIN32(GetLastError());
HeapFree(GetProcessHeap(), 0, str); HeapFree(GetProcessHeap(), 0, str);
end: end:

View file

@ -233,6 +233,7 @@ HFCI __cdecl FCICreate(
p_fci_internal->estimatedCabinetSize = 0; p_fci_internal->estimatedCabinetSize = 0;
p_fci_internal->statusFolderTotal = 0; p_fci_internal->statusFolderTotal = 0;
memset(&p_fci_internal->oldCCAB, 0, sizeof(CCAB));
memcpy(p_fci_internal->szPrevCab, pccab->szCab, CB_MAX_CABINET_NAME); memcpy(p_fci_internal->szPrevCab, pccab->szCab, CB_MAX_CABINET_NAME);
memcpy(p_fci_internal->szPrevDisk, pccab->szDisk, CB_MAX_DISK_NAME); memcpy(p_fci_internal->szPrevDisk, pccab->szDisk, CB_MAX_DISK_NAME);
@ -2416,6 +2417,10 @@ BOOL __cdecl FCIAddFile(
} }
/* get information about the file */ /* get information about the file */
/* set defaults in case callback doesn't set one or more fields */
cffile.attribs=0;
cffile.date=0;
cffile.time=0;
file_handle=(*pfnfcigoi)(pszSourceFile, &(cffile.date), &(cffile.time), file_handle=(*pfnfcigoi)(pszSourceFile, &(cffile.date), &(cffile.time),
&(cffile.attribs), &err, p_fci_internal->pv); &(cffile.attribs), &err, p_fci_internal->pv);
/* check file_handle */ /* check file_handle */

View file

@ -411,26 +411,6 @@ static long FDI_getoffset(HFDI hfdi, INT_PTR hf)
return PFDI_SEEK(hfdi, hf, 0L, SEEK_CUR); return PFDI_SEEK(hfdi, hf, 0L, SEEK_CUR);
} }
/**********************************************************************
* FDI_realloc (internal)
*
* we can't use _msize; the user might not be using malloc, so we require
* an explicit specification of the previous size. inefficient.
*/
static void *FDI_realloc(HFDI hfdi, void *mem, size_t prevsize, size_t newsize)
{
void *rslt = NULL;
char *irslt, *imem;
size_t copysize = (prevsize < newsize) ? prevsize : newsize;
if (prevsize == newsize) return mem;
rslt = PFDI_ALLOC(hfdi, newsize);
if (rslt)
for (irslt = (char *)rslt, imem = (char *)mem; (copysize); copysize--)
*irslt++ = *imem++;
PFDI_FREE(hfdi, mem);
return rslt;
}
/********************************************************************** /**********************************************************************
* FDI_read_string (internal) * FDI_read_string (internal)
* *
@ -439,19 +419,17 @@ static void *FDI_realloc(HFDI hfdi, void *mem, size_t prevsize, size_t newsize)
static char *FDI_read_string(HFDI hfdi, INT_PTR hf, long cabsize) static char *FDI_read_string(HFDI hfdi, INT_PTR hf, long cabsize)
{ {
size_t len=256, size_t len=256,
oldlen = 0,
base = FDI_getoffset(hfdi, hf), base = FDI_getoffset(hfdi, hf),
maxlen = cabsize - base; maxlen = cabsize - base;
BOOL ok = FALSE; BOOL ok = FALSE;
unsigned int i; unsigned int i;
cab_UBYTE *buf = NULL; cab_UBYTE *buf = NULL;
TRACE("(hfdi == ^%p, hf == %ld)\n", hfdi, hf); TRACE("(hfdi == ^%p, hf == %ld, cabsize == %ld)\n", hfdi, hf, cabsize);
do { do {
if (len > maxlen) len = maxlen; if (len > maxlen) len = maxlen;
if (!(buf = FDI_realloc(hfdi, buf, oldlen, len))) break; if (!(buf = PFDI_ALLOC(hfdi, len))) break;
oldlen = len;
if (!PFDI_READ(hfdi, hf, buf, len)) break; if (!PFDI_READ(hfdi, hf, buf, len)) break;
/* search for a null terminator in what we've just read */ /* search for a null terminator in what we've just read */
@ -464,8 +442,13 @@ static char *FDI_read_string(HFDI hfdi, INT_PTR hf, long cabsize)
ERR("cabinet is truncated\n"); ERR("cabinet is truncated\n");
break; break;
} }
len += 256; /* The buffer is too small for the string. Reset the file to the point
* were we started, free the buffer and increase the size for the next try
*/
PFDI_SEEK(hfdi, hf, base, SEEK_SET); PFDI_SEEK(hfdi, hf, base, SEEK_SET);
PFDI_FREE(hfdi, buf);
buf = NULL;
len *= 2;
} }
} while (!ok); } while (!ok);
@ -2128,7 +2111,7 @@ static int fdi_decomp(const struct fdi_file *fi, int savemode, fdi_decomp_state
TRACE("full cab path/file name: %s\n", debugstr_a(fullpath)); TRACE("full cab path/file name: %s\n", debugstr_a(fullpath));
/* try to get a handle to the cabfile */ /* try to get a handle to the cabfile */
cabhf = PFDI_OPEN(CAB(hfdi), fullpath, 32768, _S_IREAD | _S_IWRITE); cabhf = PFDI_OPEN(CAB(hfdi), fullpath, _O_RDONLY|_O_BINARY, _S_IREAD | _S_IWRITE);
if (cabhf == -1) { if (cabhf == -1) {
/* no file. allow the user to try again */ /* no file. allow the user to try again */
fdin.fdie = FDIERROR_CABINET_NOT_FOUND; fdin.fdie = FDIERROR_CABINET_NOT_FOUND;
@ -2492,10 +2475,9 @@ BOOL __cdecl FDICopy(
TRACE("full cab path/file name: %s\n", debugstr_a(fullpath)); TRACE("full cab path/file name: %s\n", debugstr_a(fullpath));
/* get a handle to the cabfile */ /* get a handle to the cabfile */
cabhf = PFDI_OPEN(hfdi, fullpath, 32768, _S_IREAD | _S_IWRITE); cabhf = PFDI_OPEN(hfdi, fullpath, _O_RDONLY|_O_BINARY, _S_IREAD | _S_IWRITE);
if (cabhf == -1) { if (cabhf == -1) {
PFDI_INT(hfdi)->perf->erfOper = FDIERROR_CABINET_NOT_FOUND; PFDI_INT(hfdi)->perf->erfOper = FDIERROR_CABINET_NOT_FOUND;
PFDI_INT(hfdi)->perf->erfType = ERROR_FILE_NOT_FOUND;
PFDI_INT(hfdi)->perf->fError = TRUE; PFDI_INT(hfdi)->perf->fError = TRUE;
SetLastError(ERROR_FILE_NOT_FOUND); SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE; return FALSE;