]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/ftp.cpp
Ignore non-existant string selection in wxComboBox::SetValue() in read-only mode...
[wxWidgets.git] / src / common / ftp.cpp
index 519d7c561838f4c4cb5d02fdd9f1f6313fd00622..49cba58de659abfb04abf2daca185caf1418268c 100644 (file)
@@ -155,11 +155,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 +203,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
     {
@@ -960,15 +963,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