[PATCH] improve virtual directory support for IIS FTP servers



Yet another ugly FTP hack:

http://bugzilla.gnome.org/show_bug.cgi?id=119245

This protocol is teh suck [no stat!] :(.

-- 
Christian Neumair <chris gnome-de org>
Index: modules/ftp-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/ftp-method.c,v
retrieving revision 1.127
diff -u -p -r1.127 ftp-method.c
--- modules/ftp-method.c	25 Apr 2006 11:27:50 -0000	1.127
+++ modules/ftp-method.c	11 Jul 2006 15:17:12 -0000
@@ -2392,6 +2393,40 @@ do_get_file_info (GnomeVFSMethod *method
 		}
 		g_free (name);
 		do_close_directory (method, method_handle, context);
+
+		/* maybe it was a hidden directory not included in ls output
+		 * (IIS virtual directory), so try to CWD to it. */
+		if (result == GNOME_VFS_ERROR_NOT_FOUND) {
+			FtpConnection *connection;
+
+			if (ftp_connection_acquire (uri, &connection, context) == GNOME_VFS_OK) {
+				result = do_path_command (connection, "CWD", uri, get_cancellation (context));
+				ftp_connection_release (connection, FALSE);
+			}
+
+			if (result == GNOME_VFS_OK) {
+				char *unescaped;
+				char *basename;
+
+				unescaped = gnome_vfs_unescape_string (uri->text, G_DIR_SEPARATOR_S);
+				basename = g_path_get_basename (unescaped);
+				g_free (unescaped);
+
+				if (basename != NULL) {
+					file_info->name = basename;
+					file_info->type = GNOME_VFS_FILE_TYPE_DIRECTORY;
+					file_info->mime_type = g_strdup ("x-directory/normal");
+					file_info->valid_fields = GNOME_VFS_FILE_INFO_FIELDS_TYPE |
+						GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE;
+				} else {
+					result = GNOME_VFS_ERROR_NOT_FOUND;
+				}
+			}
+
+			if (result != GNOME_VFS_OK) {
+				result = GNOME_VFS_ERROR_NOT_FOUND;
+			}
+		}
 	}
 
 	return result;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]