[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error in FTP_get ( FTPAPI )



   We have discovered that in case the file does not exist on the remote
   server when doing a FTP_get()
   an empty file is created on the local server.


   This is an extract of the source of FTPAPIR4  version 2.2 but as far as
   I can see the error also exists on version 2.3:


   * open the file to
   retrieve

   c                   eval      wwFD = OpnFile(wwLocal: 'W':
   p_write:

   c                                         p_close:
   peSocket)

   c                   if        wwFD <
   0

   c                   return
   -1

   c
   endif



    * download into the
   file...

   c                   eval      wwRC = FTP_getraw(peSocket:
   peRemote:

   c                                     wwFD:
   p_write)

   c                   if        wwRC <
   0

   c                   callp
   CloseMe(wwFD)

   c                   return
   -1

   c
   endif



    * we're done...
   woohoo

   c                   callp
   CloseMe(wwFD)

   c                   return
   0


   The error happens when OpnFile() is called. It creates the empty file
   on the IFS.

   When FTP_getraw() is called it fails causing the local file to be
   closed but not deleted.


   It could be fixed in two ways:

   1)      UNLINK() the file on the IFS before issuing the return -1.

   2)      Doing a FTP_LIST() with the remote file name as an path
   argument and then
   testing if the actual number of array elements is greater than 0.
   This method may be rather ineffective.


   Kind regards

   Peder Udesen

   ***********************************************************************
   *********
   This email and any files transmitted with it may be confidential and
   intended solely for the use of the individual or entity to which they
   are addressed. If you have received this email in error please notify
   the sender.
   ***********************************************************************
   *********
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------