summaryrefslogtreecommitdiff
path: root/atari/findfile.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-05-05 22:28:51 +0100
committerVincent Sanders <vince@kyllikki.org>2016-05-15 13:44:34 +0100
commitd21447d096a320a08b3efb2b8768fad0dcdcfd64 (patch)
tree1a83814b7c9e94b2f13c473261f23dd3a17dee64 /atari/findfile.c
parent2cbb337756d9af5bda4d594964d446439f602551 (diff)
downloadnetsurf-d21447d096a320a08b3efb2b8768fad0dcdcfd64.tar.gz
netsurf-d21447d096a320a08b3efb2b8768fad0dcdcfd64.tar.bz2
move frontends into sub directory
Diffstat (limited to 'atari/findfile.c')
-rw-r--r--atari/findfile.c144
1 files changed, 0 insertions, 144 deletions
diff --git a/atari/findfile.c b/atari/findfile.c
deleted file mode 100644
index 45ca6d916..000000000
--- a/atari/findfile.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2010 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <unistd.h>
-
-#include "utils/log.h"
-#include "utils/corestrings.h"
-
-#include "atari/gemtk/gemtk.h"
-#include "atari/findfile.h"
-#include "atari/gui.h"
-#include "atari/osspec.h"
-
-char * local_file_to_url( const char * filename )
-{
- #define BACKSLASH 0x5C
- char * url;
-
- LOG("in: %s", filename);
-
- if( strlen(filename) <= 2){
- return( NULL );
- }
-
- char * fname_local = malloc( strlen(filename)+1 );
- char * start = (char*)fname_local;
- strcpy( start, filename );
-
- /* convert backslashes: */
- for( unsigned int i=0; i<strlen(start); i++ ){
- if( start[i] == BACKSLASH ){
- start[i] = '/';
- }
- }
-
- // TODO: make file path absolute if it isn't yet.
- url = malloc( strlen(start) + FILE_SCHEME_PREFIX_LEN + 1);
- strcpy(url, FILE_SCHEME_PREFIX );
- strcat(url, start );
-
- free(fname_local);
-
- LOG("out: %s", url);
-
- return( url );
- #undef BACKSLASH
-}
-
-
-/**
- * Locate a shared resource file by searching known places in order.
- * Search order is: ./, NETSURF_GEM_RESPATH, ./$HOME/.netsurf/, $NETSURFRES/
- * (where NETSURFRES is an environment variable)
- *
- * \param buf buffer to write to. must be at least PATH_MAX chars
- * \param filename file to look for
- * \param def default to return if file not found
- * \return buf
- *
- */
-#ifndef NETSURF_GEM_RESPATH
- #define NETSURF_GEM_RESPATH "./res/"
-#endif
-
-char * atari_find_resource(char *buf, const char *filename, const char *def)
-{
- char *cdir = NULL;
- char t[PATH_MAX];
- LOG("%s (def: %s)", filename, def);
- strcpy(t, NETSURF_GEM_RESPATH);
- strcat(t, filename);
- LOG("checking %s", (char *)&t);
- if (gemdos_realpath(t, buf) != NULL) {
- if (access(buf, R_OK) == 0) {
- return buf;
- }
- }
- strcpy(t, "./");
- strcat(t, filename);
- LOG("checking %s", (char *)&t);
- if (gemdos_realpath(t, buf) != NULL) {
- if (access(buf, R_OK) == 0) {
- return buf;
- }
- }
-
- cdir = getenv("HOME");
- if (cdir != NULL) {
- strcpy(t, cdir);
- strcat(t, "/.netsurf/");
- strcat(t, filename);
- LOG("checking %s", (char *)&t);
- if (gemdos_realpath(t, buf) != NULL) {
- if (access(buf, R_OK) == 0)
- return buf;
- }
- }
-
- cdir = getenv("NETSURFRES");
- if (cdir != NULL) {
- if (gemdos_realpath(cdir, buf) != NULL) {
- strcat(buf, "/");
- strcat(buf, filename);
- LOG("checking %s", (char *)&t);
- if (access(buf, R_OK) == 0)
- return buf;
- }
- }
- if (def[0] == '~') {
- snprintf(t, PATH_MAX, "%s%s", getenv("HOME"), def + 1);
- LOG("checking %s", (char *)&t);
- if (gemdos_realpath(t, buf) == NULL) {
- strcpy(buf, t);
- }
- } else {
- LOG("checking %s", (char *)def);
- if (gemdos_realpath(def, buf) == NULL) {
- strcpy(buf, def);
- }
- }
-
- return buf;
-}
-
-/*
- * Local Variables:
- * c-basic-offset: 8
- * End:
- */