diff options
author | Ole Loots <ole@monochrom.net> | 2011-01-10 23:51:52 +0000 |
---|---|---|
committer | Ole Loots <ole@monochrom.net> | 2011-01-10 23:51:52 +0000 |
commit | 5f62669c20c3c79d5bb3b427a996533e1e376b0c (patch) | |
tree | 610e54e1b08965a095f2922a110777be714ba52d /atari | |
parent | ae44623e0dff2602173e8b04d4d56799287ce60f (diff) | |
download | netsurf-5f62669c20c3c79d5bb3b427a996533e1e376b0c.tar.gz netsurf-5f62669c20c3c79d5bb3b427a996533e1e376b0c.tar.bz2 |
Added realpath() for plain TOS systems.
svn path=/trunk/netsurf/; revision=11282
Diffstat (limited to 'atari')
-rwxr-xr-x[-rw-r--r--] | atari/findfile.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/atari/findfile.c b/atari/findfile.c index befe0eeb5..995865c9f 100644..100755 --- a/atari/findfile.c +++ b/atari/findfile.c @@ -57,6 +57,59 @@ char *url_to_path(const char *url) return path; } + +#ifdef PLAIN_TOS +#undef realpath +#undef access +#define access(f,m) (0) +#define PATH_SEP '/' +char * realpath(const char * path, char * rpath) +{ + size_t l; + size_t i; + char old; + char new = PATH_SEP; + + if( rpath == NULL ){ + return( NULL ); + } + + if( PATH_SEP == '/') { + /* replace '\' with / */ + old = 0x2F; /* / */ + } else { + /* replace '/' with \ */ + old = '/'; + } + + if( path[0] == 0x2F || path[0] == '/' ){ + strcpy(rpath, "U:"); + strcat(rpath, path); + } + else if( path[0] == '.') { + char cwd[PATH_MAX]; + getcwd((char*)&cwd, PATH_MAX); + strcpy(rpath, (char*)&cwd); + if( (path[1] == '/' || path[1] == 0x27 ) ) { + strcat(rpath, &path[1]); + } else { + strcat(rpath, "/"); + strcat(rpath, path); + } + } else { + strcpy(rpath, path); + } + /* convert path seperator to configured value: */ + l = strlen(rpath); + for( i = 0; i<l-1; i++){ + if( rpath[i] == old ){ + rpath[i] = new; + } + } + return( rpath ); +} +#endif + /** * Locate a shared resource file by searching known places in order. * @@ -136,6 +189,7 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) } + /* * Local Variables: * c-basic-offset: 8 |