summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/dirlist.c3
-rw-r--r--content/dirlist.h2
-rw-r--r--content/fetchers/file.c19
3 files changed, 13 insertions, 11 deletions
diff --git a/content/dirlist.c b/content/dirlist.c
index 8ed977239..433e21026 100644
--- a/content/dirlist.c
+++ b/content/dirlist.c
@@ -177,7 +177,8 @@ bool dirlist_generate_title(const char *title, char *buffer, int buffer_length)
* dirlist_generate_bottom()
*/
-bool dirlist_generate_parent_link(char *parent, char *buffer, int buffer_length)
+bool dirlist_generate_parent_link(const char *parent, char *buffer,
+ int buffer_length)
{
int error = snprintf(buffer, buffer_length,
"<p><a href=\"%s\">%s</a></p>",
diff --git a/content/dirlist.h b/content/dirlist.h
index 7228ae231..bf90ec6d4 100644
--- a/content/dirlist.h
+++ b/content/dirlist.h
@@ -36,7 +36,7 @@
bool dirlist_generate_top(char *buffer, int buffer_length);
bool dirlist_generate_hide_columns(int flags, char *buffer, int buffer_length);
bool dirlist_generate_title(const char *title, char *buffer, int buffer_length);
-bool dirlist_generate_parent_link(char *parent, char *buffer,
+bool dirlist_generate_parent_link(const char *parent, char *buffer,
int buffer_length);
bool dirlist_generate_headings(char *buffer, int buffer_length);
bool dirlist_generate_row(bool even, bool directory, char *url, char *name,
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;