You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/12/13 17:14:53 UTC

[incubator-nuttx-apps] 02/04: netutils/ftpc: add config for using binary type for size command

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 4a56546811eac830d998815e8f005aa7720fff5d
Author: Juha Niskanen <ju...@haltian.com>
AuthorDate: Sun Dec 13 17:27:39 2020 +0200

    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 <ju...@haltian.com>
---
 netutils/ftpc/Kconfig         |  6 ++++++
 netutils/ftpc/ftpc_filesize.c | 27 ++++++---------------------
 2 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/netutils/ftpc/Kconfig b/netutils/ftpc/Kconfig
index ff3f031..9df8694 100644
--- a/netutils/ftpc/Kconfig
+++ b/netutils/ftpc/Kconfig
@@ -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
diff --git a/netutils/ftpc/ftpc_filesize.c b/netutils/ftpc/ftpc_filesize.c
index 4e886f5..efd3419 100644
--- a/netutils/ftpc/ftpc_filesize.c
+++ b/netutils/ftpc/ftpc_filesize.c
@@ -47,26 +47,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;
     }