X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..4164a04a98be1066038317c2d16438cce3f59c81:/src/common/ftp.cpp diff --git a/src/common/ftp.cpp b/src/common/ftp.cpp index 519d7c5618..dfda3b0c8c 100644 --- a/src/common/ftp.cpp +++ b/src/common/ftp.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: common/ftp.cpp +// Name: src/common/ftp.cpp // Purpose: FTP protocol // Author: Guilhem Lavaux // Modified by: Mark Johnson, wxWindows@mj10777.de @@ -48,9 +48,7 @@ #include "wx/protocol/protocol.h" #include "wx/protocol/ftp.h" -#ifndef __MWERKS__ - #include -#endif +#include // ---------------------------------------------------------------------------- // constants @@ -155,11 +153,15 @@ bool wxFTP::Connect(const wxSockAddress& addr, bool WXUNUSED(wait)) return true; } -bool wxFTP::Connect(const wxString& host) +bool wxFTP::Connect(const wxString& host, unsigned short port) { wxIPV4address addr; addr.Hostname(host); - addr.Service(wxT("ftp")); + + if ( port ) + addr.Service(port); + else if (!addr.Service(wxT("ftp"))) + addr.Service(21); return Connect(addr); } @@ -199,8 +201,7 @@ wxSocketBase *wxFTP::AcceptIfActive(wxSocketBase *sock) { m_lastError = wxPROTO_CONNERR; wxLogError(_("Timeout while waiting for FTP server to connect, try passive mode.")); - delete sock; - sock = NULL; + wxDELETE(sock); } else { @@ -584,9 +585,9 @@ wxSocketBase *wxFTP::GetActivePort() addrNew.Service(0); // pick an open port number. wxSocketServer *sockSrv = new wxSocketServer(addrNew); - if (!sockSrv->Ok()) + if (!sockSrv->IsOk()) { - // We use Ok() here to see if everything is ok + // We use IsOk() here to see if everything is ok m_lastError = wxPROTO_PROTERR; delete sockSrv; return NULL; @@ -683,7 +684,7 @@ public: // when checking the result, the stream will // almost always show an error, even if the file was - // properly transfered, thus, lets just grab the result + // properly transferred, thus, let's just grab the result // we are looking for "226 transfer completed" char code = m_ftp->GetResult(); @@ -899,7 +900,7 @@ int wxFTP::GetFileSize(const wxString& fileName) int filesize = -1; - // Check for existance of file via wxFTP::FileExists(...) + // Check for existence of file via wxFTP::FileExists(...) if ( FileExists(fileName) ) { wxString command; @@ -936,7 +937,7 @@ int wxFTP::GetFileSize(const wxString& fileName) } // Set transfermode back to the original. Only the "SIZE"-command - // is dependant on transfermode + // is dependent on transfermode if ( oldTransfermode != NONE ) { SetTransferMode(oldTransfermode); @@ -960,15 +961,15 @@ int wxFTP::GetFileSize(const wxString& fileName) // substring containing the name we are looking for. We // stop the iteration at the first occurrence of the // filename. The search is not case-sensitive. - bool foundIt = false; - + const size_t numFiles = fileList.size(); size_t i; - for ( i = 0; !foundIt && i < fileList.GetCount(); i++ ) + for ( i = 0; i < fileList.GetCount(); i++ ) { - foundIt = fileList[i].Upper().Contains(fileName.Upper()); + if ( fileList[i].Upper().Contains(fileName.Upper()) ) + break; } - if ( foundIt ) + if ( i != numFiles ) { // The index i points to the first occurrence of // fileName in the array Now we have to find out what