From 29ad56b4b239dfafd9f15a0499d496798bd061d7 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 6 Oct 2012 14:07:34 +0100 Subject: Use nsurl_parent. --- content/fetchers/file.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/content/fetchers/file.c b/content/fetchers/file.c index 73bfbdb3b..4c02c0c60 100644 --- a/content/fetchers/file.c +++ b/content/fetchers/file.c @@ -48,6 +48,7 @@ #include "content/urldb.h" #include "desktop/netsurf.h" #include "desktop/options.h" +#include "utils/errors.h" #include "utils/log.h" #include "utils/messages.h" #include "utils/url.h" @@ -493,10 +494,9 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx, char buffer[1024]; /* Output buffer */ bool even = false; /* formatting flag */ char *title; /* pretty printed title */ - url_func_result res; /* result from url routines */ - char *up; /* url of parent */ + nserror err; /* result from url routines */ + nsurl *up; /* url of parent */ char *path; /* url for list entries */ - bool compare; /* result of url compare */ DIR *scandir; /* handle for enumerating the directory */ struct dirent* ent; /* leaf directory entry */ @@ -541,16 +541,17 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx, goto fetch_file_process_dir_aborted; /* Print parent directory link */ - res = url_parent(nsurl_access(ctx->url), &up); - if (res == URL_FUNC_OK) { - res = url_compare(nsurl_access(ctx->url), up, false, &compare); - if ((res == URL_FUNC_OK) && compare == false) { - dirlist_generate_parent_link(up, buffer, sizeof buffer); + err = nsurl_parent(ctx->url, &up); + if (err == NSERROR_OK) { + if (nsurl_compare(ctx->url, up, NSURL_COMPLETE) == false) { + /* different URL; have parent */ + dirlist_generate_parent_link(nsurl_access(up), + buffer, sizeof buffer); msg.data.header_or_data.len = strlen(buffer); fetch_file_send_callback(&msg, ctx); } - free(up); + nsurl_unref(up); if (ctx->aborted) goto fetch_file_process_dir_aborted; -- cgit v1.2.3