[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/kioslave/ftp
From:       David Faure <faure () kde ! org>
Date:       2005-03-03 18:49:28
Message-ID: 20050303184928.66261148A2 () office ! kde ! org
[Download RAW message or body]

CVS commit by faure: 

Fix parsing of Netware FTP servers, so that files don't all appear with a lock (no \
                permissions).
BUG: 76442


  M +179 -172  ftp.cc   1.218


--- kdelibs/kioslave/ftp/ftp.cc  #1.217:1.218
@@ -1749,4 +1749,9 @@ bool Ftp::ftpReadDir(FtpEntry& de)
     kdDebug(7102) << "dir > " << buffer << endl;
 
+    //Normally the listing looks like
+    // -rw-r--r--   1 dfaure   dfaure        102 Nov  9 12:30 log
+    // but on Netware servers like ftp://ci-1.ci.pwr.wroc.pl/ it looks like (#76442)
+    // d [RWCEAFMS] Admin                     512 Oct 13  2004 PSI
+
     // we should always get the following 5 fields ...
     const char *p_access, *p_junk, *p_owner, *p_group, *p_size;
@@ -1757,5 +1762,11 @@ bool Ftp::ftpReadDir(FtpEntry& de)
     if( (p_size  = strtok(NULL," ")) == 0) continue;
 
-    // try to parse it as a directory entry ...
+    //kdDebug(7102) << "p_access=" << p_access << " p_junk=" << p_junk << " \
p_owner=" << p_owner << " p_group=" << p_group << " p_size=" << p_size << endl; +
+    de.access = 0;
+    if ( strlen( p_access ) == 1 && p_junk[0] == '[' ) { // Netware
+      de.access = S_IRWXU | S_IRWXG | S_IRWXO; // unknown -> give all permissions
+    }
+
     const char *p_date_1, *p_date_2, *p_date_3, *p_name;
 
@@ -1772,5 +1783,6 @@ bool Ftp::ftpReadDir(FtpEntry& de)
             // Check whether the size we just read was really the size
             // or a month (this happens when the server lists no group)
-            // Test on sunsite.uio.no, for instance
+    // Used to be the case on sunsite.uio.no, but not anymore
+    // This is needed for the Netware case, too.
             if ( !isdigit( *p_size ) )
             {
@@ -1786,10 +1798,9 @@ bool Ftp::ftpReadDir(FtpEntry& de)
             }
 
-            if ( p_date_1 != 0 )
-              if ((p_date_2 = strtok(NULL," ")) != 0)
-                if ((p_date_3 = strtok(NULL," ")) != 0)
-                  if ((p_name = strtok(NULL,"\r\n")) != 0)
+    if ( p_date_1 != 0 &&
+         (p_date_2 = strtok(NULL," ")) != 0 &&
+         (p_date_3 = strtok(NULL," ")) != 0 &&
+         (p_name = strtok(NULL,"\r\n")) != 0 )
                   {
-
                     {
                        QCString tmp( p_name );
@@ -1817,5 +1828,4 @@ bool Ftp::ftpReadDir(FtpEntry& de)
                     }
 
-                    de.access = 0;
                     de.type = S_IFREG;
                     switch ( p_access[0] ) {
@@ -1865,7 +1875,4 @@ bool Ftp::ftpReadDir(FtpEntry& de)
                       de.access |= S_ISVTX;
 
-                    // maybe fromLocal8Bit would be better in some cases,
-                    // but what proves that the ftp server is in the same encoding
-                    // than the user ??
                     de.owner    = remoteEncoding()->decode(p_owner);
                     de.group    = remoteEncoding()->decode(p_group);
@@ -1930,5 +1937,5 @@ bool Ftp::ftpReadDir(FtpEntry& de)
                     return true;
                   }
-  }
+  } // line invalid, loop to get another line
   return false;
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic