X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/469e1e5c35e3d284dc53e58dda12426be1aa2c25..e296ac9f3d5fb224e0717b2ff410b913905f6b5f:/src/common/ftp.cpp?ds=inline diff --git a/src/common/ftp.cpp b/src/common/ftp.cpp index ee2ac234d5..2b01b3a3e9 100644 --- a/src/common/ftp.cpp +++ b/src/common/ftp.cpp @@ -20,9 +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" @@ -76,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; @@ -245,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) @@ -324,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; @@ -339,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) @@ -384,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