summaryrefslogtreecommitdiff
path: root/atari
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-05-26 23:43:36 +0100
committerVincent Sanders <vince@kyllikki.org>2014-05-26 23:52:36 +0100
commit00b6cfc57e27f8146d9b41ba8e63038a4f9df70e (patch)
treebadf71a43a81975098d3f1294073d8c76bc994ea /atari
parent1f337f292d1c98c396d5f8d5d294f9ba13963586 (diff)
downloadnetsurf-00b6cfc57e27f8146d9b41ba8e63038a4f9df70e.tar.gz
netsurf-00b6cfc57e27f8146d9b41ba8e63038a4f9df70e.tar.bz2
rework path to url mapping functions to convert from and to nsurl
Diffstat (limited to 'atari')
-rwxr-xr-xatari/findfile.c53
-rwxr-xr-xatari/findfile.h2
-rw-r--r--atari/gui.c10
-rwxr-xr-xatari/misc.c20
4 files changed, 8 insertions, 77 deletions
diff --git a/atari/findfile.c b/atari/findfile.c
index 7badc7149..356a9333f 100755
--- a/atari/findfile.c
+++ b/atari/findfile.c
@@ -68,59 +68,6 @@ char * local_file_to_url( const char * filename )
#undef BACKSLASH
}
-/* convert an local path to an URL, memory for URL is allocated. */
-char *path_to_url(const char *path_in)
-{
- #define BACKSLASH 0x5C
- char * path;
-
- LOG(("path2url in: %s\n", path_in));
-
- path = (char*)path_in;
-
- int urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1;
- char *url = malloc(urllen);
-
- snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, path);
-
- int i=0;
- while( url[i] != 0 ){
- if( url[i] == BACKSLASH ){
- url[i] = '/';
- }
- i++;
- }
-
- LOG(("path2url out: %s\n", url));
- return url;
- #undef BACKSLASH
-}
-
-
-char *url_to_path(const char *url)
-{
- char *url_path = curl_unescape(url, 0);
- char *path;
- char abspath[PATH_MAX+1];
-
- LOG(( "url2path in: %s (%s)\n", url, url_path ));
-
- // is the URL relative?
- if (url_path[7] == '.') {
- // yes, make it absolute...
- gemdos_realpath(url_path + (FILE_SCHEME_PREFIX_LEN-1), abspath);
- path = strdup(abspath);
- } else {
- path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN));
- }
-
- curl_free(url_path);
-
- LOG(( "url2path out: %s\n", path ));
-
- return path;
-}
-
/**
* Locate a shared resource file by searching known places in order.
diff --git a/atari/findfile.h b/atari/findfile.h
index cced0092c..9a6f7848a 100755
--- a/atari/findfile.h
+++ b/atari/findfile.h
@@ -23,7 +23,5 @@
extern char *atari_find_resource(char *buf, const char *filename, const char *def);
char *local_file_to_url(const char *filename);
-char *path_to_url(const char *path_in);
-char *url_to_path(const char *url);
#endif /* NETSURF_ATARI_FINDFILE_H */
diff --git a/atari/gui.c b/atari/gui.c
index 317f68013..7cac90c3b 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -890,15 +890,11 @@ static inline void create_cursor(int flags, short mode, void * form,
static nsurl *gui_get_resource_url(const char *path)
{
char buf[PATH_MAX];
- char *raw;
nsurl *url = NULL;
atari_find_resource((char*)&buf, path, path);
- raw = path_to_url((char*)&buf);
- if (raw != NULL) {
- nsurl_create(raw, &url);
- free(raw);
- }
+
+ netsurf_path_to_nsurl(buf, &url);
return url;
}
@@ -1042,8 +1038,6 @@ static struct gui_clipboard_table atari_clipboard_table = {
static struct gui_fetch_table atari_fetch_table = {
.filetype = fetch_filetype,
- .path_to_url = path_to_url,
- .url_to_path = url_to_path,
.get_resource_url = gui_get_resource_url,
};
diff --git a/atari/misc.c b/atari/misc.c
index 35ef18e52..a84ce2bd3 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -210,7 +210,6 @@ static nserror load_icon_callback(hlcache_handle *handle,
hlcache_handle *load_icon(const char *name, hlcache_handle_callback cb,
void * pw )
{
- char *url = NULL;
const char *icon_url = NULL;
hlcache_handle *c;
nserror err;
@@ -220,7 +219,7 @@ hlcache_handle *load_icon(const char *name, hlcache_handle_callback cb,
/** @todo something like bitmap_from_disc is needed here */
if (!strncmp(name, "file://", 7)) {
- icon_url = name;
+ err = nsurl_create(name, &icon_nsurl);
} else {
char *native_path = NULL;
@@ -228,22 +227,15 @@ hlcache_handle *load_icon(const char *name, hlcache_handle_callback cb,
return NULL;
err = netsurf_mkpath(&native_path, NULL, 2, icons_dir, name);
- if (err != NSERROR_OK) {
- warn_user(messages_get_errorcode(err), 0);
- return NULL;
+ if (err == NSERROR_OK) {
+ /* Convert native path to URL */
+ err = netsurf_path_to_nsurl(native_path, &icon_nsurl);
+ free(native_path);
}
-
- /* Convert native path to URL */
- url = path_to_url(native_path);
-
- free(native_path);
- icon_url = url;
}
- err = nsurl_create(icon_url, &icon_nsurl);
if (err != NSERROR_OK) {
- if (url != NULL)
- free(url);
+ warn_user(messages_get_errorcode(err), 0);
return NULL;
}