Commit 8c45eecc authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Moved InternetFindNextFileW implementation to vtbl.

parent 34002d4c
......@@ -1170,7 +1170,8 @@ static const HANDLEHEADERVtbl FTPFILEVtbl = {
FTPFILE_Destroy,
NULL,
NULL,
FTPFILE_WriteFile
FTPFILE_WriteFile,
NULL
};
/***********************************************************************
......@@ -2088,6 +2089,7 @@ static const HANDLEHEADERVtbl FTPSESSIONVtbl = {
FTPSESSION_Destroy,
FTPSESSION_CloseConnection,
NULL,
NULL,
NULL
};
......@@ -3083,91 +3085,97 @@ recv_end:
return (nRC != -1);
}
/***********************************************************************
* FTP_FindNextFileW (Internal)
*
* Continues a file search from a previous call to FindFirstFile
*
* RETURNS
* TRUE on success
* FALSE on failure
* FTPFINDNEXT_Destroy (internal)
*
* Deallocate session handle
*/
BOOL WINAPI FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh, LPVOID lpvFindData)
static void FTPFINDNEXT_Destroy(WININETHANDLEHEADER *hdr)
{
BOOL bSuccess = TRUE;
LPWIN32_FIND_DATAW lpFindFileData;
TRACE("index(%d) size(%d)\n", lpwh->index, lpwh->size);
assert (lpwh->hdr.htype == WH_HFTPFINDNEXT);
LPWININETFTPFINDNEXTW lpwfn = (LPWININETFTPFINDNEXTW) hdr;
DWORD i;
/* Clear any error information */
INTERNET_SetLastError(0);
TRACE("\n");
lpFindFileData = (LPWIN32_FIND_DATAW) lpvFindData;
ZeroMemory(lpFindFileData, sizeof(WIN32_FIND_DATAA));
WININET_Release(&lpwfn->lpFtpSession->hdr);
if (lpwh->index >= lpwh->size)
for (i = 0; i < lpwfn->size; i++)
{
INTERNET_SetLastError(ERROR_NO_MORE_FILES);
bSuccess = FALSE;
goto lend;
HeapFree(GetProcessHeap(), 0, lpwfn->lpafp[i].lpszName);
}
FTP_ConvertFileProp(&lpwh->lpafp[lpwh->index], lpFindFileData);
lpwh->index++;
HeapFree(GetProcessHeap(), 0, lpwfn->lpafp);
HeapFree(GetProcessHeap(), 0, lpwfn);
}
TRACE("\nName: %s\nSize: %d\n", debugstr_w(lpFindFileData->cFileName), lpFindFileData->nFileSizeLow);
static DWORD WINAPI FTPFINDNEXT_FindNextFileProc(WININETFTPFINDNEXTW *find, LPVOID data)
{
WIN32_FIND_DATAW *find_data = data;
DWORD res = ERROR_SUCCESS;
lend:
TRACE("index(%d) size(%d)\n", find->index, find->size);
ZeroMemory(find_data, sizeof(WIN32_FIND_DATAW));
if (lpwh->hdr.dwFlags & INTERNET_FLAG_ASYNC)
if (find->index < find->size) {
FTP_ConvertFileProp(&find->lpafp[find->index], find_data);
find->index++;
TRACE("Name: %s\nSize: %d\n", debugstr_w(find_data->cFileName), find_data->nFileSizeLow);
}else {
res = ERROR_NO_MORE_FILES;
}
if (find->hdr.dwFlags & INTERNET_FLAG_ASYNC)
{
INTERNET_ASYNC_RESULT iar;
iar.dwResult = (DWORD)bSuccess;
iar.dwError = iar.dwError = bSuccess ? ERROR_SUCCESS :
INTERNET_GetLastError();
iar.dwResult = (res == ERROR_SUCCESS);
iar.dwError = res;
INTERNET_SendCallback(&lpwh->hdr, lpwh->hdr.dwContext,
INTERNET_SendCallback(&find->hdr, find->hdr.dwContext,
INTERNET_STATUS_REQUEST_COMPLETE, &iar,
sizeof(INTERNET_ASYNC_RESULT));
}
return bSuccess;
return res;
}
/***********************************************************************
* FTPFINDNEXT_Destroy (internal)
*
* Deallocate session handle
*/
static void FTPFINDNEXT_Destroy(WININETHANDLEHEADER *hdr)
static void FTPFINDNEXT_AsyncFindNextFileProc(WORKREQUEST *workRequest)
{
LPWININETFTPFINDNEXTW lpwfn = (LPWININETFTPFINDNEXTW) hdr;
DWORD i;
struct WORKREQ_FTPFINDNEXTW *req = &workRequest->u.FtpFindNextW;
TRACE("\n");
FTPFINDNEXT_FindNextFileProc((WININETFTPFINDNEXTW*)workRequest->hdr, req->lpFindFileData);
}
WININET_Release(&lpwfn->lpFtpSession->hdr);
static DWORD FTPFINDNEXT_FindNextFileW(WININETHANDLEHEADER *hdr, void *data)
{
WININETFTPFINDNEXTW *find = (WININETFTPFINDNEXTW*)hdr;
for (i = 0; i < lpwfn->size; i++)
if (find->lpFtpSession->lpAppInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC)
{
HeapFree(GetProcessHeap(), 0, lpwfn->lpafp[i].lpszName);
WORKREQUEST workRequest;
struct WORKREQ_FTPFINDNEXTW *req;
workRequest.asyncproc = FTPFINDNEXT_AsyncFindNextFileProc;
workRequest.hdr = WININET_AddRef( &find->hdr );
req = &workRequest.u.FtpFindNextW;
req->lpFindFileData = data;
INTERNET_AsyncCall(&workRequest);
return ERROR_SUCCESS;
}
HeapFree(GetProcessHeap(), 0, lpwfn->lpafp);
HeapFree(GetProcessHeap(), 0, lpwfn);
return FTPFINDNEXT_FindNextFileProc(find, data);
}
static const HANDLEHEADERVtbl FTPFINDNEXTVtbl = {
FTPFINDNEXT_Destroy,
NULL,
NULL,
NULL
NULL,
FTPFINDNEXT_FindNextFileW
};
/***********************************************************************
......
......@@ -1422,7 +1422,8 @@ static const HANDLEHEADERVtbl HTTPREQVtbl = {
HTTPREQ_Destroy,
HTTPREQ_CloseConnection,
HTTPREQ_SetOption,
HTTPREQ_WriteFile
HTTPREQ_WriteFile,
NULL
};
/***********************************************************************
......@@ -2946,6 +2947,7 @@ static const HANDLEHEADERVtbl HTTPSESSIONVtbl = {
HTTPSESSION_Destroy,
NULL,
NULL,
NULL,
NULL
};
......
......@@ -475,6 +475,7 @@ static const HANDLEHEADERVtbl APPINFOVtbl = {
APPINFO_Destroy,
NULL,
NULL,
NULL,
NULL
};
......@@ -944,53 +945,32 @@ BOOL WINAPI InternetFindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
* FALSE on failure
*
*/
static void AsyncFtpFindNextFileProc(WORKREQUEST *workRequest)
{
struct WORKREQ_FTPFINDNEXTW *req = &workRequest->u.FtpFindNextW;
LPWININETFTPFINDNEXTW lpwh = (LPWININETFTPFINDNEXTW) workRequest->hdr;
TRACE("%p\n", lpwh);
FTP_FindNextFileW(lpwh, req->lpFindFileData);
}
BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
{
LPWININETAPPINFOW hIC = NULL;
LPWININETFTPFINDNEXTW lpwh;
BOOL bSuccess = FALSE;
WININETHANDLEHEADER *hdr;
DWORD res;
TRACE("\n");
lpwh = (LPWININETFTPFINDNEXTW) WININET_GetObject( hFind );
if (NULL == lpwh || lpwh->hdr.htype != WH_HFTPFINDNEXT)
{
FIXME("Only FTP supported\n");
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
goto lend;
hdr = WININET_GetObject(hFind);
if(!hdr) {
WARN("Invalid handle\n");
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
hIC = lpwh->lpFtpSession->lpAppInfo;
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
{
WORKREQUEST workRequest;
struct WORKREQ_FTPFINDNEXTW *req;
if(hdr->vtbl->FindNextFileW) {
res = hdr->vtbl->FindNextFileW(hdr, lpvFindData);
}else {
WARN("Handle doesn't support NextFile\n");
res = ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
}
workRequest.asyncproc = AsyncFtpFindNextFileProc;
workRequest.hdr = WININET_AddRef( &lpwh->hdr );
req = &workRequest.u.FtpFindNextW;
req->lpFindFileData = lpvFindData;
WININET_Release(hdr);
bSuccess = INTERNET_AsyncCall(&workRequest);
}
else
{
bSuccess = FTP_FindNextFileW(lpwh, lpvFindData);
}
lend:
if( lpwh )
WININET_Release( &lpwh->hdr );
return bSuccess;
if(res != ERROR_SUCCESS)
SetLastError(res);
return res == ERROR_SUCCESS;
}
/***********************************************************************
......
......@@ -140,6 +140,7 @@ typedef struct {
void (*CloseConnection)(WININETHANDLEHEADER*);
DWORD (*SetOption)(WININETHANDLEHEADER*,DWORD,void*,DWORD);
BOOL (*WriteFile)(WININETHANDLEHEADER*,const void*,DWORD,DWORD*);
DWORD (*FindNextFileW)(WININETHANDLEHEADER*,void*);
} HANDLEHEADERVtbl;
struct _WININETHANDLEHEADER
......@@ -429,7 +430,6 @@ BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDire
BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD_PTR dwContext);
BOOL WINAPI FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh, LPVOID lpvFindData);
BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
LPDWORD lpdwCurrentDirectory);
BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
......
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