X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/19ae5cf071340a670f8ad4e808aff1657c648c5c..58a33cb4e6e2de9d6ea6da16b52e53d840797059:/src/common/ftp.cpp diff --git a/src/common/ftp.cpp b/src/common/ftp.cpp index 00d44539cd..2b01b3a3e9 100644 --- a/src/common/ftp.cpp +++ b/src/common/ftp.cpp @@ -20,7 +20,15 @@ #pragma hdrstop #endif +#if wxUSE_SOCKETS + +#ifndef __MWERKS__ #include +#endif +#if defined(__WXMAC__) +#include "/wx/mac/macsock.h" +#endif + #include #include "wx/string.h" #include "wx/utils.h" @@ -74,7 +82,7 @@ wxFTP::~wxFTP() //////////////////////////////////////////////////////////////// ////// wxFTP connect and login methods ///////////////////////// //////////////////////////////////////////////////////////////// -bool wxFTP::Connect(wxSockAddress& addr) +bool wxFTP::Connect(wxSockAddress& addr, bool WXUNUSED(wait)) { if (!m_handler) { m_lastError = wxPROTO_NOHNDLR; @@ -158,12 +166,12 @@ bool wxFTP::GetResult(char exp) { if ((m_lastError = GetLine(this, m_lastResult))) return FALSE; - if (m_lastResult[0] != exp) { + if (m_lastResult.GetChar(0) != exp) { m_lastError = wxPROTO_PROTERR; return FALSE; } - if (m_lastResult[3] == '-') { + if (m_lastResult.GetChar(3) == '-') { wxString key = m_lastResult.Left((size_t)3); key += ' '; @@ -243,9 +251,11 @@ bool wxFTP::RmFile(const wxString& path) class wxInputFTPStream : public wxSocketInputStream { public: wxFTP *m_ftp; + size_t m_ftpsize; wxInputFTPStream(wxFTP *ftp_clt, wxSocketBase *sock) : wxSocketInputStream(*sock), m_ftp(ftp_clt) {} + size_t StreamSize() const { return m_ftpsize; } virtual ~wxInputFTPStream(void) { if (LastError() != wxStream_NOERROR) @@ -322,6 +332,8 @@ bool wxFTP::Abort(void) wxInputStream *wxFTP::GetInputStream(const wxString& path) { wxString tmp_str; + int pos_size; + wxInputFTPStream *in_stream; if (!SendCommand("TYPE I", '2')) return NULL; @@ -337,7 +349,16 @@ wxInputStream *wxFTP::GetInputStream(const wxString& path) if (!SendCommand(tmp_str, '1')) return NULL; - return new wxInputFTPStream(this, sock); + in_stream = new wxInputFTPStream(this, sock); + + pos_size = m_lastResult.Index('('); + if (pos_size != wxNOT_FOUND) { + wxString str_size = m_lastResult(pos_size+1, m_lastResult.Index(')')-1); + + in_stream->m_ftpsize = atoi(WXSTRINGCAST str_size); + } + + return in_stream; } wxOutputStream *wxFTP::GetOutputStream(const wxString& path) @@ -382,5 +403,11 @@ wxList *wxFTP::GetList(const wxString& wildcard) return NULL; } + sock->SetEventHandler(*GetNextHandler(), m_id); + sock->Notify(m_notifyme); + sock->SetNotify(m_neededreq); + return file_list; } +#endif + // wxUSE_SOCKETS