# HG changeset patch # User masneyb # Date 1089772422 0 # Node ID ba50a7085d935199e714e42aa2f22022716507a1 # Parent 39e9945288eae288e39ddb5aa82ec9fe6add75a9 2004-7-13 Brian Masney * 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 diff -r 39e9945288ea -r ba50a7085d93 ChangeLog --- a/ChangeLog Tue Jul 13 20:17:42 2004 +0000 +++ b/ChangeLog Wed Jul 14 02:33:42 2004 +0000 @@ -1,4 +1,13 @@ 2004-7-13 Brian Masney + * 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 + * lib/gftp.h lib/local.c lib/misc.c lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c src/gtk/chmod_dialog.c src/gtk/delete_dialog.c src/gtk/dnd.c src/gtk/gftp-gtk.c src/gtk/gtkui_transfer.c @@ -2558,7 +2567,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.278 2004/07/13 20:17:42 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.279 2004/07/14 02:33:42 masneyb Exp $ tags * debian/* - updated files from Debian maintainer diff -r 39e9945288ea -r ba50a7085d93 lib/gftp.h --- a/lib/gftp.h Tue Jul 13 20:17:42 2004 +0000 +++ b/lib/gftp.h Wed Jul 14 02:33:42 2004 +0000 @@ -424,6 +424,8 @@ size_t size ); int (*end_transfer) ( gftp_request * request ); int (*abort_transfer) ( gftp_request * request ); + mode_t (*stat_filename) ( gftp_request * request, + const char *filename ); int (*list_files) ( gftp_request * request ); int (*get_next_file) ( gftp_request * request, gftp_file *fle, @@ -888,6 +890,9 @@ int gftp_abort_transfer ( gftp_request * request ); +mode_t gftp_stat_filename ( gftp_request * request, + const char *filename ); + void gftp_set_hostname ( gftp_request * request, const char *hostname ); diff -r 39e9945288ea -r ba50a7085d93 lib/local.c --- a/lib/local.c Tue Jul 13 20:17:42 2004 +0000 +++ b/lib/local.c Wed Jul 14 02:33:42 2004 +0000 @@ -220,6 +220,18 @@ } +static mode_t +local_stat_filename (gftp_request * request, const char *filename) +{ + struct stat st; + + if (stat (filename, &st) != 0) + return (GFTP_ERETRYABLE); + + return (st.st_mode); +} + + static int local_get_next_file (gftp_request * request, gftp_file * fle, int fd) { @@ -577,6 +589,7 @@ request->put_next_file_chunk = NULL; request->end_transfer = local_end_transfer; request->abort_transfer = local_end_transfer; /* NOTE: uses end_transfer */ + request->stat_filename = local_stat_filename; request->list_files = local_list_files; request->get_next_file = local_get_next_file; request->get_next_dirlist_line = NULL; diff -r 39e9945288ea -r ba50a7085d93 lib/protocols.c --- 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; diff -r 39e9945288ea -r ba50a7085d93 lib/rfc2068.c --- a/lib/rfc2068.c Tue Jul 13 20:17:42 2004 +0000 +++ b/lib/rfc2068.c Wed Jul 14 02:33:42 2004 +0000 @@ -919,6 +919,7 @@ request->put_next_file_chunk = NULL; request->end_transfer = rfc2068_end_transfer; request->abort_transfer = rfc2068_end_transfer; /* NOTE: uses end_transfer */ + request->stat_filename = NULL; request->list_files = rfc2068_list_files; request->get_next_file = rfc2068_get_next_file; request->get_next_dirlist_line = NULL; diff -r 39e9945288ea -r ba50a7085d93 lib/rfc959.c --- a/lib/rfc959.c Tue Jul 13 20:17:42 2004 +0000 +++ b/lib/rfc959.c Wed Jul 14 02:33:42 2004 +0000 @@ -1809,6 +1809,7 @@ request->put_next_file_chunk = rfc959_put_next_file_chunk; request->end_transfer = rfc959_end_transfer; request->abort_transfer = rfc959_abort_transfer; + request->stat_filename = NULL; request->list_files = rfc959_list_files; request->get_next_file = rfc959_get_next_file; request->get_next_dirlist_line = rfc959_get_next_dirlist_line; diff -r 39e9945288ea -r ba50a7085d93 lib/sshv2.c --- a/lib/sshv2.c Tue Jul 13 20:17:42 2004 +0000 +++ b/lib/sshv2.c Wed Jul 14 02:33:42 2004 +0000 @@ -1211,6 +1211,8 @@ { if ((num = sshv2_buffer_get_int32 (request, message, -1)) < 0) return (num); + + fle->st_mode = num; } if (attrs & SSH_FILEXFER_ATTR_ACMODTIME) @@ -1229,7 +1231,6 @@ if ((count = sshv2_buffer_get_int32 (request, message, -1)) < 0) return (GFTP_EFATAL); - printf ("FIXME - file %d extended attributes\n", count); for (i=0; iprotonum == GFTP_SSHV2_NUM, GFTP_EFATAL); - g_return_val_if_fail (file != NULL, GFTP_EFATAL); + g_return_val_if_fail (filename != NULL, GFTP_EFATAL); len = 0; - tempstr = sshv2_initialize_string_with_path (request, file, &len, NULL); + tempstr = sshv2_initialize_string_with_path (request, filename, &len, NULL); ret = sshv2_send_command (request, SSH_FXP_STAT, tempstr, len); @@ -1695,28 +1695,61 @@ if (ret < 0) return (ret); - serv_ret = sshv2_read_status_response (request, &message, -1, SSH_FXP_STATUS, - SSH_FXP_ATTRS); - if (serv_ret < 0) - return (serv_ret); + ret = sshv2_read_status_response (request, &message, -1, SSH_FXP_STATUS, + SSH_FXP_ATTRS); + if (ret < 0) + return (ret); if (message.length < 5) return (GFTP_EFATAL); message.pos += 4; - memset (&fle, 0, sizeof (fle)); - if ((serv_ret = sshv2_decode_file_attributes (request, &message, &fle)) < 0) + if ((ret = sshv2_decode_file_attributes (request, &message, fle)) < 0) { - gftp_file_destroy (&fle); - return (serv_ret); + gftp_file_destroy (fle); + return (ret); } - ret = fle.size; - gftp_file_destroy (&fle); sshv2_message_free (&message); + return (0); +} + + +static mode_t +sshv2_stat_filename (gftp_request * request, const char *filename) +{ + gftp_file fle; + mode_t ret; + + memset (&fle, 0, sizeof (fle)); + ret = sshv2_send_stat_command (request, filename, &fle); + if (ret < 0) + return (ret); + + ret = fle.st_mode; + gftp_file_destroy (&fle); + return (ret); +} + +static off_t +sshv2_get_file_size (gftp_request * request, const char *file) +{ + gftp_file fle; + off_t size; + int ret; + + memset (&fle, 0, sizeof (fle)); + ret = sshv2_send_stat_command (request, file, &fle); + if (ret < 0) + return (ret); + + size = fle.size; + gftp_file_destroy (&fle); + + return (size); } @@ -2047,6 +2080,7 @@ request->put_next_file_chunk = sshv2_put_next_file_chunk; request->end_transfer = sshv2_end_transfer; request->abort_transfer = sshv2_end_transfer; /* NOTE: uses sshv2_end_transfer */ + request->stat_filename = sshv2_stat_filename; request->list_files = sshv2_list_files; request->get_next_file = sshv2_get_next_file; request->get_next_dirlist_line = NULL; diff -r 39e9945288ea -r ba50a7085d93 src/gtk/misc-gtk.c --- a/src/gtk/misc-gtk.c Tue Jul 13 20:17:42 2004 +0000 +++ b/src/gtk/misc-gtk.c Wed Jul 14 02:33:42 2004 +0000 @@ -693,7 +693,7 @@ gftp_get_pixmap (wdata->listbox, "linkdir.xpm", &pix, &bitmap); else if (S_ISLNK (fle->st_mode)) gftp_get_pixmap (wdata->listbox, "linkfile.xpm", &pix, &bitmap); - else if (S_ISLNK (fle->st_mode)) + else if (S_ISDIR (fle->st_mode)) gftp_get_pixmap (wdata->listbox, "dir.xpm", &pix, &bitmap); else if ((fle->st_mode & S_IXUSR) || (fle->st_mode & S_IXGRP) ||