From f222ec79e981f3409a45d7031bbe69f47719c8a8 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Sat, 22 Jan 2011 16:27:26 +0000 Subject: Improved path fixes for classic TOS systems. svn path=/trunk/netsurf/; revision=11439 --- atari/findfile.c | 112 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 74 insertions(+), 38 deletions(-) (limited to 'atari/findfile.c') diff --git a/atari/findfile.c b/atari/findfile.c index 995865c9f..3a90c026d 100755 --- a/atari/findfile.c +++ b/atari/findfile.c @@ -22,13 +22,18 @@ #include #include #include - #include +#include #include "utils/log.h" #include "utils/url.h" - #include "atari/findfile.h" +#include "atari/gui.h" +#include "atari/misc.h" + +extern unsigned short gdosversion; + +static void fix_path(char * path); char *path_to_url(const char *path) { @@ -51,49 +56,86 @@ char *url_to_path(const char *url) char *path; /* return the absolute path including leading / */ - path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN - 1)); + /* TODO: fix path seperator */ + if(gdosversion > TOS4VER ) { + path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN - 1)); + } else { + /* do not include / within ulr_path */ + path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN)); + int l = strlen(path); + int i; + for( i = 0; i TOS4VER ){ + return( realpath(path, rpath) ); + } - if( PATH_SEP == '/') { + if( fsep == '/') { /* replace '\' with / */ - old = 0x2F; /* / */ + old = 0x5C; /* / */ } else { /* replace '/' with \ */ old = '/'; } - if( path[0] == 0x2F || path[0] == '/' ){ - strcpy(rpath, "U:"); - strcat(rpath, path); - } - else if( path[0] == '.') { + if( path[0] != '/' && path[0] != 0x5c && path[1] != ':') { + /* it is not an absolute path */ char cwd[PATH_MAX]; getcwd((char*)&cwd, PATH_MAX); + fix_path((char*)&cwd); strcpy(rpath, (char*)&cwd); - if( (path[1] == '/' || path[1] == 0x27 ) ) { - strcat(rpath, &path[1]); + l = strlen(rpath); + if(rpath[l-1] != 0x5C && rpath[l-1] != '/') { + rpath[l] = fsep; + rpath[l+1] = 0; + } + if( (path[1] == '/' || path[1] == 0x5C ) ) { + strcat(rpath, &path[2]); } else { - strcat(rpath, "/"); strcat(rpath, path); } } else { @@ -103,12 +145,12 @@ char * realpath(const char * path, char * rpath) l = strlen(rpath); for( i = 0; i