Commit 91312d7d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Move ftp FindNextFile implementation to ftp.c.

parent 2a50d52c
......@@ -2706,6 +2706,64 @@ static void FTP_CloseSessionHandle(LPWININETHANDLEHEADER hdr)
/***********************************************************************
* 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);
assert(lpwh->hdr.lpwhparent->htype == WH_HFTPSESSION);
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;
}
/***********************************************************************
* FTP_CloseFindNextHandle (internal)
*
* Deallocate session handle
......@@ -2717,7 +2775,7 @@ static void FTP_CloseSessionHandle(LPWININETHANDLEHEADER hdr)
*/
static void FTP_CloseFindNextHandle(LPWININETHANDLEHEADER hdr)
{
LPWININETFINDNEXTW lpwfn = (LPWININETFINDNEXTW) hdr;
LPWININETFTPFINDNEXTW lpwfn = (LPWININETFTPFINDNEXTW) hdr;
DWORD i;
TRACE("\n");
......@@ -2777,7 +2835,7 @@ static HINTERNET FTP_ReceiveFileList(LPWININETFTPSESSIONW lpwfs, INT nSocket, LP
{
DWORD dwSize = 0;
LPFILEPROPERTIESW lpafp = NULL;
LPWININETFINDNEXTW lpwfn = NULL;
LPWININETFTPFINDNEXTW lpwfn = NULL;
HINTERNET handle = 0;
TRACE("(%p,%d,%s,%p,%d)\n", lpwfs, nSocket, debugstr_w(lpszSearchFile), lpFindFileData, dwContext);
......@@ -2787,10 +2845,10 @@ static HINTERNET FTP_ReceiveFileList(LPWININETFTPSESSIONW lpwfs, INT nSocket, LP
if(lpFindFileData)
FTP_ConvertFileProp(lpafp, lpFindFileData);
lpwfn = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETFINDNEXTW));
lpwfn = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETFTPFINDNEXTW));
if (lpwfn)
{
lpwfn->hdr.htype = WH_HFINDNEXT;
lpwfn->hdr.htype = WH_HFTPFINDNEXT;
lpwfn->hdr.lpwhparent = WININET_AddRef( &lpwfs->hdr );
lpwfn->hdr.dwContext = dwContext;
lpwfn->hdr.dwRefCount = 1;
......
......@@ -85,7 +85,6 @@ typedef struct
} WITHREADERROR, *LPWITHREADERROR;
static VOID INTERNET_CloseHandle(LPWININETHANDLEHEADER hdr);
BOOL WINAPI INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh, LPVOID lpvFindData);
HINTERNET WINAPI INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC, LPCWSTR lpszUrl,
LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext);
static VOID INTERNET_ExecuteWork(void);
......@@ -943,14 +942,15 @@ BOOL WINAPI InternetFindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
{
LPWININETAPPINFOW hIC = NULL;
LPWININETFINDNEXTW lpwh;
LPWININETFTPFINDNEXTW lpwh;
BOOL bSuccess = FALSE;
TRACE("\n");
lpwh = (LPWININETFINDNEXTW) WININET_GetObject( hFind );
if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
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;
}
......@@ -959,18 +959,18 @@ BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
{
WORKREQUEST workRequest;
struct WORKREQ_INTERNETFINDNEXTW *req;
struct WORKREQ_FTPFINDNEXTW *req;
workRequest.asyncall = INTERNETFINDNEXTW;
workRequest.asyncall = FTPFINDNEXTW;
workRequest.hdr = WININET_AddRef( &lpwh->hdr );
req = &workRequest.u.InternetFindNextW;
req = &workRequest.u.FtpFindNextW;
req->lpFindFileData = lpvFindData;
bSuccess = INTERNET_AsyncCall(&workRequest);
}
else
{
bSuccess = INTERNET_FindNextFileW(lpwh, lpvFindData);
bSuccess = FTP_FindNextFileW(lpwh, lpvFindData);
}
lend:
if( lpwh )
......@@ -979,71 +979,6 @@ lend:
}
/***********************************************************************
* INTERNET_FindNextFileW (Internal)
*
* Continues a file search from a previous call to FindFirstFile
*
* RETURNS
* TRUE on success
* FALSE on failure
*
*/
BOOL WINAPI INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh, LPVOID lpvFindData)
{
BOOL bSuccess = TRUE;
LPWIN32_FIND_DATAW lpFindFileData;
TRACE("\n");
assert (lpwh->hdr.htype == WH_HFINDNEXT);
/* Clear any error information */
INTERNET_SetLastError(0);
if (lpwh->hdr.lpwhparent->htype != WH_HFTPSESSION)
{
FIXME("Only FTP find next supported\n");
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
return FALSE;
}
TRACE("index(%d) size(%d)\n", lpwh->index, lpwh->size);
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;
}
/***********************************************************************
* INTERNET_CloseHandle (internal)
*
* Close internet handle
......@@ -3439,15 +3374,15 @@ static VOID INTERNET_ExecuteWork(void)
}
break;
case INTERNETFINDNEXTW:
case FTPFINDNEXTW:
{
struct WORKREQ_INTERNETFINDNEXTW *req;
LPWININETFINDNEXTW lpwh = (LPWININETFINDNEXTW) workRequest.hdr;
struct WORKREQ_FTPFINDNEXTW *req;
LPWININETFTPFINDNEXTW lpwh = (LPWININETFTPFINDNEXTW) workRequest.hdr;
TRACE("INTERNETFINDNEXTW %p\n", lpwh);
req = &workRequest.u.InternetFindNextW;
INTERNET_FindNextFileW(lpwh, req->lpFindFileData);
req = &workRequest.u.FtpFindNextW;
FTP_FindNextFileW(lpwh, req->lpFindFileData);
}
break;
......
......@@ -124,7 +124,7 @@ typedef enum
WH_HGOPHERSESSION = INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
WH_HHTTPSESSION = INTERNET_HANDLE_TYPE_CONNECT_HTTP,
WH_HFILE = INTERNET_HANDLE_TYPE_FTP_FILE,
WH_HFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
WH_HFTPFINDNEXT = INTERNET_HANDLE_TYPE_FTP_FIND,
WH_HHTTPREQ = INTERNET_HANDLE_TYPE_HTTP_REQUEST,
} WH_TYPE;
......@@ -241,7 +241,7 @@ typedef struct
DWORD index;
DWORD size;
LPFILEPROPERTIESW lpafp;
} WININETFINDNEXTW, *LPWININETFINDNEXTW;
} WININETFTPFINDNEXTW, *LPWININETFTPFINDNEXTW;
typedef enum
{
......@@ -255,7 +255,7 @@ typedef enum
FTPDELETEFILEW,
FTPREMOVEDIRECTORYW,
FTPRENAMEFILEW,
INTERNETFINDNEXTW,
FTPFINDNEXTW,
HTTPSENDREQUESTW,
HTTPOPENREQUESTW,
SENDCALLBACK,
......@@ -329,7 +329,7 @@ struct WORKREQ_FTPRENAMEFILEW
LPWSTR lpszDestFile;
};
struct WORKREQ_INTERNETFINDNEXTW
struct WORKREQ_FTPFINDNEXTW
{
LPWIN32_FIND_DATAW lpFindFileData;
};
......@@ -394,7 +394,7 @@ typedef struct WORKREQ
struct WORKREQ_FTPDELETEFILEW FtpDeleteFileW;
struct WORKREQ_FTPREMOVEDIRECTORYW FtpRemoveDirectoryW;
struct WORKREQ_FTPRENAMEFILEW FtpRenameFileW;
struct WORKREQ_INTERNETFINDNEXTW InternetFindNextW;
struct WORKREQ_FTPFINDNEXTW FtpFindNextW;
struct WORKREQ_HTTPOPENREQUESTW HttpOpenRequestW;
struct WORKREQ_HTTPSENDREQUESTW HttpSendRequestW;
struct WORKREQ_SENDCALLBACK SendCallback;
......@@ -441,6 +441,7 @@ 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 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