From f6f1fe1ceefc31f254184684596d84a84f17c67a Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 11 Jul 2010 14:55:12 +0000 Subject: Allow browsing directories. Clicking through from the root of a volume doesn't work (needs some url_to_path translation magic or an #ifdef'd patch in render/directory.c) and the [..] parent link always points to "file:///" for some reason, but other than that it works. svn path=/trunk/netsurf/; revision=10627 --- amiga/fetch_file.c | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'amiga') diff --git a/amiga/fetch_file.c b/amiga/fetch_file.c index 8624b469a..b443b9b54 100755 --- a/amiga/fetch_file.c +++ b/amiga/fetch_file.c @@ -45,6 +45,7 @@ struct ami_file_fetch_info { char *url; /**< URL of this fetch. */ bool aborted; bool locked; + bool is_dir; struct nsObject *obj; int httpcode; int64 len; @@ -296,17 +297,49 @@ void ami_fetch_file_poll(const char *scheme_ignored) } else { + char header[64]; STRPTR errorstring; + struct ExamineData *fib; + if(fib = ExamineObjectTags(EX_StringNameInput,fetch->path,TAG_DONE)) + { + if(EXD_IS_DIRECTORY(fib)) fetch->is_dir = true; + FreeDosObject(DOS_EXAMINEDATA,fib); + } + + if(fetch->is_dir == true) + { + fetch_set_http_code(fetch->fetch_handle, 200); + fetch->mimetype = fetch_mimetype(fetch->path); + LOG(("mimetype %s", fetch->mimetype)); + + snprintf(header, sizeof header, + "Content-Type: %s", + fetch->mimetype); + ami_fetch_file_send_callback(FETCH_HEADER, + fetch, header, strlen(header), errorcode); - errorstring = ASPrintf("%s %s",messages_get("FileError"),fetch->path); - fetch_set_http_code(fetch->fetch_handle,404); + ami_fetch_file_send_callback( + FETCH_DATA, fetch, + fetch->path, + strlen(fetch->path), errorcode); + + ami_fetch_file_send_callback(FETCH_FINISHED, + fetch, NULL, 0, + errorcode); + + fetch->aborted = true; + } + else + { + errorstring = ASPrintf("%s %s",messages_get("FileError"),fetch->path); + fetch_set_http_code(fetch->fetch_handle,404); - errorcode = FETCH_ERROR_HTTP_NOT2; - ami_fetch_file_send_callback(FETCH_ERROR, fetch, - errorstring, 0, - errorcode); - fetch->aborted = true; - FreeVec(errorstring); + errorcode = FETCH_ERROR_HTTP_NOT2; + ami_fetch_file_send_callback(FETCH_ERROR, fetch, + errorstring, 0, errorcode); + fetch->aborted = true; + FreeVec(errorstring); + } } } } -- cgit v1.2.3