summaryrefslogtreecommitdiff
path: root/utils/filename.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/filename.c')
-rw-r--r--utils/filename.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/utils/filename.c b/utils/filename.c
index 82a0c9965..8b64ccfc8 100644
--- a/utils/filename.c
+++ b/utils/filename.c
@@ -19,6 +19,7 @@
#include <sys/stat.h>
#include "netsurf/utils/filename.h"
#include "netsurf/utils/log.h"
+#include "netsurf/utils/url.h"
#include "netsurf/utils/utils.h"
#define FULL_WORD (unsigned int)4294967295
@@ -422,3 +423,26 @@ static struct directory *filename_create_directory(const char *prefix) {
return new_dir;
}
+
+
+/**
+ * Converts a filename into a local URL
+ *
+ * \param filename the filename to convert
+ * \return a local URL allocated on heap, or NULL on failure.
+ */
+char *filename_as_url(const char *filename) {
+ char *temp, *url;
+ int length;
+
+ length = strlen(TEMP_FILENAME_PREFIX) + strlen(filename) + 2;
+ temp = malloc(length);
+ if (!temp) {
+ LOG(("No memory for malloc()"));
+ return NULL;
+ }
+ sprintf(temp, "%s/%s", TEMP_FILENAME_PREFIX, filename);
+ url = path_to_url(temp);
+ free(temp);
+ return url;
+}