wininet/ftp.c: Fix some returned error codes.
This commit is contained in:
parent
ea8ccb2590
commit
8316b93386
|
@ -1027,12 +1027,26 @@ HINTERNET WINAPI FtpOpenFileW(HINTERNET hFtpSession,
|
||||||
debugstr_w(lpszFileName), fdwAccess, dwFlags, dwContext);
|
debugstr_w(lpszFileName), fdwAccess, dwFlags, dwContext);
|
||||||
|
|
||||||
lpwfs = (LPWININETFTPSESSIONW) WININET_GetObject( hFtpSession );
|
lpwfs = (LPWININETFTPSESSIONW) WININET_GetObject( hFtpSession );
|
||||||
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
|
if (!lpwfs)
|
||||||
|
{
|
||||||
|
INTERNET_SetLastError(ERROR_INVALID_HANDLE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WH_HFTPSESSION != lpwfs->hdr.htype)
|
||||||
{
|
{
|
||||||
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
||||||
goto lend;
|
goto lend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((!lpszFileName) ||
|
||||||
|
((fdwAccess != GENERIC_READ) && (fdwAccess != GENERIC_WRITE)) ||
|
||||||
|
((dwFlags & FTP_CONDITION_MASK) > FTP_TRANSFER_TYPE_BINARY))
|
||||||
|
{
|
||||||
|
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
goto lend;
|
||||||
|
}
|
||||||
|
|
||||||
if (lpwfs->download_in_progress != NULL) {
|
if (lpwfs->download_in_progress != NULL) {
|
||||||
INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
|
INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
|
||||||
goto lend;
|
goto lend;
|
||||||
|
@ -1060,7 +1074,6 @@ HINTERNET WINAPI FtpOpenFileW(HINTERNET hFtpSession,
|
||||||
}
|
}
|
||||||
|
|
||||||
lend:
|
lend:
|
||||||
if( lpwfs )
|
|
||||||
WININET_Release( &lpwfs->hdr );
|
WININET_Release( &lpwfs->hdr );
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -409,7 +409,6 @@ static void test_openfile(void)
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
hOpenFile = FtpOpenFileA(NULL, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
|
hOpenFile = FtpOpenFileA(NULL, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
|
||||||
ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
|
ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
|
||||||
todo_wine
|
|
||||||
ok ( GetLastError() == ERROR_INVALID_HANDLE,
|
ok ( GetLastError() == ERROR_INVALID_HANDLE,
|
||||||
"Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
|
"Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
|
||||||
InternetCloseHandle(hOpenFile); /* Just in case */
|
InternetCloseHandle(hOpenFile); /* Just in case */
|
||||||
|
@ -429,7 +428,6 @@ static void test_openfile(void)
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
hOpenFile = FtpOpenFileA(hFtp, NULL, GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
|
hOpenFile = FtpOpenFileA(hFtp, NULL, GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
|
||||||
ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
|
ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
|
||||||
todo_wine
|
|
||||||
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
|
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||||
InternetCloseHandle(hOpenFile); /* Just in case */
|
InternetCloseHandle(hOpenFile); /* Just in case */
|
||||||
|
@ -438,7 +436,6 @@ static void test_openfile(void)
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", 0, FTP_TRANSFER_TYPE_ASCII, 0);
|
hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", 0, FTP_TRANSFER_TYPE_ASCII, 0);
|
||||||
ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
|
ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
|
||||||
todo_wine
|
|
||||||
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
|
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||||
InternetCloseHandle(hOpenFile); /* Just in case */
|
InternetCloseHandle(hOpenFile); /* Just in case */
|
||||||
|
@ -447,7 +444,6 @@ static void test_openfile(void)
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ|GENERIC_WRITE, FTP_TRANSFER_TYPE_ASCII, 0);
|
hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ|GENERIC_WRITE, FTP_TRANSFER_TYPE_ASCII, 0);
|
||||||
ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
|
ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
|
||||||
todo_wine
|
|
||||||
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
|
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||||
InternetCloseHandle(hOpenFile); /* Just in case */
|
InternetCloseHandle(hOpenFile); /* Just in case */
|
||||||
|
@ -455,28 +451,23 @@ static void test_openfile(void)
|
||||||
/* Illegal condition flags */
|
/* Illegal condition flags */
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, 5, 0);
|
hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, 5, 0);
|
||||||
todo_wine
|
|
||||||
{
|
|
||||||
ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
|
ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
|
||||||
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
|
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||||
}
|
|
||||||
InternetCloseHandle(hOpenFile); /* Just in case */
|
InternetCloseHandle(hOpenFile); /* Just in case */
|
||||||
|
|
||||||
/* All OK */
|
/* All OK */
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
|
hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
|
||||||
todo_wine
|
|
||||||
{
|
|
||||||
ok ( hOpenFile != NULL, "Expected FtpOpenFileA to succeed\n");
|
ok ( hOpenFile != NULL, "Expected FtpOpenFileA to succeed\n");
|
||||||
/* For some strange/unknown reason, win98 returns ERROR_FILE_NOT_FOUND */
|
/* For some strange/unknown reason, win98 returns ERROR_FILE_NOT_FOUND */
|
||||||
ok ( GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_FILE_NOT_FOUND,
|
ok ( GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_FILE_NOT_FOUND,
|
||||||
"Expected ERROR_SUCCESS or ERROR_FILE_NOT_FOUND (win98), got %d\n", GetLastError());
|
"Expected ERROR_SUCCESS or ERROR_FILE_NOT_FOUND (win98), got %d\n", GetLastError());
|
||||||
}
|
|
||||||
|
|
||||||
if (hOpenFile)
|
if (hOpenFile)
|
||||||
{
|
{
|
||||||
BOOL bRet;
|
BOOL bRet;
|
||||||
|
HINTERNET hOpenFile2;
|
||||||
|
|
||||||
/* We have a handle so all ftp calls should fail (TODO: Put more ftp-calls in here) */
|
/* We have a handle so all ftp calls should fail (TODO: Put more ftp-calls in here) */
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
|
@ -485,6 +476,13 @@ static void test_openfile(void)
|
||||||
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
|
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
|
||||||
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
|
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
|
||||||
DeleteFileA("should_be_non_existing_deadbeef"); /* Just in case */
|
DeleteFileA("should_be_non_existing_deadbeef"); /* Just in case */
|
||||||
|
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
hOpenFile2 = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
|
||||||
|
ok ( bRet == FALSE, "Expected FtpOpenFileA to fail\n");
|
||||||
|
ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
|
||||||
|
"Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
|
||||||
|
InternetCloseHandle(hOpenFile); /* Just in case */
|
||||||
}
|
}
|
||||||
|
|
||||||
InternetCloseHandle(hOpenFile);
|
InternetCloseHandle(hOpenFile);
|
||||||
|
|
Loading…
Reference in New Issue