diff lib/protocols.c @ 500:ba50a7085d93

2004-7-13 Brian Masney <masneyb@gftp.org> * lib/gftp.h lib/local.c lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c - added gftp_stat_filename(). This will retrieve the attributes for the selected file. When downloading a list of items, if one of the items is a symlink, check to see if it points to a directory or file * src/gtk/misc-gtk.c - fix for displaying the folder icon for directories
author masneyb
date Wed, 14 Jul 2004 02:33:42 +0000
parents 39e9945288ea
children 93d7d3b9a477
line wrap: on
line diff
--- a/lib/protocols.c	Tue Jul 13 20:17:42 2004 +0000
+++ b/lib/protocols.c	Wed Jul 14 02:33:42 2004 +0000
@@ -339,6 +339,22 @@
 }
 
 
+mode_t
+gftp_stat_filename (gftp_request * request, const char *filename)
+{
+  mode_t ret;
+
+  g_return_val_if_fail (request != NULL, GFTP_EFATAL);
+
+  if (request->stat_filename != NULL)
+    ret = request->stat_filename (request, filename);
+  else
+    ret = 0;
+
+  return (ret);
+}
+
+
 int
 gftp_list_files (gftp_request * request)
 {
@@ -1881,6 +1897,7 @@
   unsigned long *newsize;
   GHashTable * dirhash;
   gftp_file * curfle;
+  mode_t st_mode;
 
   g_return_val_if_fail (transfer != NULL, GFTP_EFATAL);
   g_return_val_if_fail (transfer->fromreq != NULL, GFTP_EFATAL);
@@ -1940,7 +1957,14 @@
     {
       curfle = templist->data;
 
-      if (S_ISDIR (curfle->st_mode))
+      if (S_ISLNK (curfle->st_mode) && !S_ISDIR (curfle->st_mode))
+        {
+          st_mode = gftp_stat_filename (transfer->fromreq, curfle->file);
+          if (S_ISDIR (st_mode))
+            curfle->st_mode = st_mode;
+        }
+
+      if (curfle->st_mode & S_IFDIR)
         {
           oldfromdir = transfer->fromreq->directory;
           transfer->fromreq->directory = curfle->file;