X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c96fd235be44ecc87404b1c2b3369e478dd82e0e..c27eab7e9ce512e052046886a33c5f5002d42573:/src/common/ftp.cpp diff --git a/src/common/ftp.cpp b/src/common/ftp.cpp index 498548bed2..2b01b3a3e9 100644 --- a/src/common/ftp.cpp +++ b/src/common/ftp.cpp @@ -12,7 +12,23 @@ #ifdef __GNUG__ #pragma implementation "ftp.h" #endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#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" @@ -66,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; @@ -150,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 += ' '; @@ -235,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) @@ -314,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; @@ -329,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) @@ -374,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