wininet: Moved InternetFindNextFileW implementation to vtbl.
This commit is contained in:
parent
34002d4c7e
commit
8c45eecca7
|
@ -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,63 +3085,6 @@ 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
|
||||
*
|
||||
*/
|
||||
BOOL WINAPI FTP_FindNextFileW(LPWININETFTPFINDNEXTW lpwh, LPVOID lpvFindData)
|
||||
{
|
||||
BOOL bSuccess = TRUE;
|
||||
LPWIN32_FIND_DATAW lpFindFileData;
|
||||
|
||||
TRACE("index(%d) size(%d)\n", lpwh->index, lpwh->size);
|
||||
|
||||
assert (lpwh->hdr.htype == WH_HFTPFINDNEXT);
|
||||
|
||||
/* Clear any error information */
|
||||
INTERNET_SetLastError(0);
|
||||
|
||||
lpFindFileData = (LPWIN32_FIND_DATAW) lpvFindData;
|
||||
ZeroMemory(lpFindFileData, sizeof(WIN32_FIND_DATAA));
|
||||
|
||||
if (lpwh->index >= lpwh->size)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_NO_MORE_FILES);
|
||||
bSuccess = FALSE;
|
||||
goto lend;
|
||||
}
|
||||
|
||||
FTP_ConvertFileProp(&lpwh->lpafp[lpwh->index], lpFindFileData);
|
||||
lpwh->index++;
|
||||
|
||||
TRACE("\nName: %s\nSize: %d\n", debugstr_w(lpFindFileData->cFileName), lpFindFileData->nFileSizeLow);
|
||||
|
||||
lend:
|
||||
|
||||
if (lpwh->hdr.dwFlags & INTERNET_FLAG_ASYNC)
|
||||
{
|
||||
INTERNET_ASYNC_RESULT iar;
|
||||
|
||||
iar.dwResult = (DWORD)bSuccess;
|
||||
iar.dwError = iar.dwError = bSuccess ? ERROR_SUCCESS :
|
||||
INTERNET_GetLastError();
|
||||
|
||||
INTERNET_SendCallback(&lpwh->hdr, lpwh->hdr.dwContext,
|
||||
INTERNET_STATUS_REQUEST_COMPLETE, &iar,
|
||||
sizeof(INTERNET_ASYNC_RESULT));
|
||||
}
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* FTPFINDNEXT_Destroy (internal)
|
||||
*
|
||||
|
@ -3163,11 +3108,74 @@ static void FTPFINDNEXT_Destroy(WININETHANDLEHEADER *hdr)
|
|||
HeapFree(GetProcessHeap(), 0, lpwfn);
|
||||
}
|
||||
|
||||
static DWORD WINAPI FTPFINDNEXT_FindNextFileProc(WININETFTPFINDNEXTW *find, LPVOID data)
|
||||
{
|
||||
WIN32_FIND_DATAW *find_data = data;
|
||||
DWORD res = ERROR_SUCCESS;
|
||||
|
||||
TRACE("index(%d) size(%d)\n", find->index, find->size);
|
||||
|
||||
ZeroMemory(find_data, sizeof(WIN32_FIND_DATAW));
|
||||
|
||||
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 = (res == ERROR_SUCCESS);
|
||||
iar.dwError = res;
|
||||
|
||||
INTERNET_SendCallback(&find->hdr, find->hdr.dwContext,
|
||||
INTERNET_STATUS_REQUEST_COMPLETE, &iar,
|
||||
sizeof(INTERNET_ASYNC_RESULT));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static void FTPFINDNEXT_AsyncFindNextFileProc(WORKREQUEST *workRequest)
|
||||
{
|
||||
struct WORKREQ_FTPFINDNEXTW *req = &workRequest->u.FtpFindNextW;
|
||||
|
||||
FTPFINDNEXT_FindNextFileProc((WININETFTPFINDNEXTW*)workRequest->hdr, req->lpFindFileData);
|
||||
}
|
||||
|
||||
static DWORD FTPFINDNEXT_FindNextFileW(WININETHANDLEHEADER *hdr, void *data)
|
||||
{
|
||||
WININETFTPFINDNEXTW *find = (WININETFTPFINDNEXTW*)hdr;
|
||||
|
||||
if (find->lpFtpSession->lpAppInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
workRequest.asyncproc = AsyncFtpFindNextFileProc;
|
||||
workRequest.hdr = WININET_AddRef( &lpwh->hdr );
|
||||
req = &workRequest.u.FtpFindNextW;
|
||||
req->lpFindFileData = lpvFindData;
|
||||
|
||||
bSuccess = INTERNET_AsyncCall(&workRequest);
|
||||
if(hdr->vtbl->FindNextFileW) {
|
||||
res = hdr->vtbl->FindNextFileW(hdr, lpvFindData);
|
||||
}else {
|
||||
WARN("Handle doesn't support NextFile\n");
|
||||
res = ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
|
||||
}
|
||||
else
|
||||
{
|
||||
bSuccess = FTP_FindNextFileW(lpwh, lpvFindData);
|
||||
}
|
||||
lend:
|
||||
if( lpwh )
|
||||
WININET_Release( &lpwh->hdr );
|
||||
return bSuccess;
|
||||
|
||||
WININET_Release(hdr);
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue