diff src/uicommon/gftpuicallbacks.c @ 355:60d3da6ab336

2003-1-5 Brian Masney <masneyb@gftp.org> * src/gtk/gftp-gtk.h src/gtk/gtkui.c - when spawning a thread, make sure that the GUI will be updated properly as soon as the thread is finished. * src/uicommon/gftpuicallbacks.c src/uicommon/gftpui.h - added gftpui_common_run_ls() * src/uicommon/gftpui.c (gftpui_common_cmd_ls) src/gtk/transfer.c (ftp_list_files) - converted these functions over to use gftpui_common_run_ls()
author masneyb
date Tue, 06 Jan 2004 01:44:09 +0000
parents e5ad008e7ea8
children d5409bf03ff1
line wrap: on
line diff
--- a/src/uicommon/gftpuicallbacks.c	Mon Jan 05 23:38:22 2004 +0000
+++ b/src/uicommon/gftpuicallbacks.c	Tue Jan 06 01:44:09 2004 +0000
@@ -79,6 +79,70 @@
 
 
 int
+gftpui_common_run_ls (gftpui_callback_data * cdata)
+{
+  int got, matched_filespec, have_dotdot;
+  intptr_t sortcol, sortasds;
+  gftp_file * fle;
+
+  if (gftp_list_files (cdata->request) != 0)
+    return (0);
+
+  have_dotdot = 0;
+  cdata->request->gotbytes = 0;
+  cdata->files = NULL;
+  fle = g_malloc0 (sizeof (*fle));
+  while ((got = gftp_get_next_file (cdata->request, NULL, fle)) > 0 ||
+         got == GFTP_ERETRYABLE)
+    {
+      if (cdata->source_string == NULL)
+        matched_filespec = 1;
+      else
+        matched_filespec = gftp_match_filespec (fle->file,
+                                                cdata->source_string);
+
+      if (got < 0 || strcmp (fle->file, ".") == 0 || !matched_filespec)
+        {
+          gftp_file_destroy (fle);
+          continue;
+        }
+      else if (strcmp (fle->file, "..") == 0)
+        have_dotdot = 1;
+
+      cdata->request->gotbytes += got;
+      cdata->files = g_list_prepend (cdata->files, fle);
+      fle = g_malloc0 (sizeof (*fle));
+    }
+  g_free (fle);
+
+  gftp_end_transfer (cdata->request);
+  cdata->request->gotbytes = -1;
+
+  if (!have_dotdot)
+    {
+      fle = g_malloc0 (sizeof (*fle));
+      fle->file = g_strdup ("..");
+      fle->user = g_malloc0 (1);
+      fle->group = g_malloc0 (1);
+      fle->attribs = g_malloc0 (1);
+      *fle->attribs = '\0';
+      fle->isdir = 1;
+      cdata->files = g_list_prepend (cdata->files, fle);
+    }
+
+  if (cdata->files != NULL)
+    {
+      gftp_lookup_global_option ("local_sortcol", &sortcol); /* FIXME */
+      gftp_lookup_global_option ("local_sortasds", &sortasds);
+    
+      cdata->files = gftp_sort_filelist (cdata->files, sortcol, sortasds);
+    }
+
+  return (1);
+}
+
+
+int
 gftpui_common_run_delete (gftpui_callback_data * cdata)
 {
   int ret;