netutils/ftpc: add config for using binary type for size command

This is handy for FOTA clients and others that always get binary files.

Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
This commit is contained in:
Juha Niskanen 2020-12-13 17:27:39 +02:00 committed by Xiang Xiao
parent 8f0e872384
commit 4a56546811
2 changed files with 12 additions and 21 deletions

View File

@ -26,6 +26,12 @@ config FTP_TMPDIR
The path to use for storing temporary files used in the transfer process
by the FTP client.
config FTP_SIZE_CMD_MODE_BINARY
bool "Use binary mode for size command"
default n
---help---
Use binary transfer mode for FTP size command.
config FTPC_DISABLE_EPRT
bool "Disable EPRT and use PORT instead"
default n

View File

@ -46,26 +46,6 @@
#include "ftpc_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -82,6 +62,7 @@ off_t ftpc_filesize(SESSION handle, FAR const char *path)
{
FAR struct ftpc_session_s *session = (FAR struct ftpc_session_s *)handle;
unsigned long ret;
uint8_t mode = FTPC_XFRMODE_ASCII;
/* Check if the host supports the SIZE command */
@ -90,7 +71,11 @@ off_t ftpc_filesize(SESSION handle, FAR const char *path)
return ERROR;
}
if (ftpc_xfrmode(session, FTPC_XFRMODE_ASCII) != 0)
#ifdef CONFIG_FTP_SIZE_CMD_MODE_BINARY
mode = FTPC_XFRMODE_BINARY;
#endif
if (ftpc_xfrmode(session, mode) != 0)
{
return ERROR;
}