X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8e907a13eae0ef1cd0eb4a318c824ba095a64684..28be2e8a170979d476a5ea4f585505b8a2f5af27:/src/common/ftp.cpp?ds=inline diff --git a/src/common/ftp.cpp b/src/common/ftp.cpp index 80c0e1a057..1d5e801965 100644 --- a/src/common/ftp.cpp +++ b/src/common/ftp.cpp @@ -20,7 +20,9 @@ #pragma hdrstop #endif -#if wxUSE_SOCKETS +#include "wx/setup.h" + +#if wxUSE_SOCKETS && wxUSE_STREAMS #ifndef __MWERKS__ #include @@ -71,6 +73,11 @@ wxFTP::wxFTP() wxFTP::~wxFTP() { + if ( m_streaming ) + { + (void)Abort(); + } + Close(); } @@ -122,17 +129,12 @@ bool wxFTP::Connect(const wxString& host) return Connect(addr); } -bool wxFTP::Close(bool force) +bool wxFTP::Close() { if ( m_streaming ) { - if ( !force ) - { - m_lastError = wxPROTO_STREAMING; - return FALSE; - } - - (void)Abort(); + m_lastError = wxPROTO_STREAMING; + return FALSE; } if ( IsConnected() ) @@ -398,11 +400,23 @@ public: : wxSocketOutputStream(*sock), m_ftp(ftp_clt) {} virtual ~wxOutputFTPStream(void) { - if (LastError() != wxStream_NOERROR) - m_ftp->GetResult('2'); - else - m_ftp->Abort(); - delete m_o_socket; + if ( IsOk() ) + { + // close data connection first, this will generate "transfer + // completed" reply + delete m_o_socket; + + // read this reply + m_ftp->GetResult('2'); + } + else + { + // abort data connection first + m_ftp->Abort(); + + // and close it after + delete m_o_socket; + } } };