From 402aaeb368844d49a92d4215ecab9ae926767bc9 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 29 Mar 2011 20:38:40 +0000 Subject: make windows frontend use svn path=/trunk/netsurf/; revision=12146 --- windows/findfile.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'windows/findfile.c') diff --git a/windows/findfile.c b/windows/findfile.c index 54fb5f4b4..b7b5bea6d 100644 --- a/windows/findfile.c +++ b/windows/findfile.c @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -29,9 +30,56 @@ #include "utils/url.h" #include "utils/log.h" #include "utils/utils.h" +#include "utils/filepath.h" #include "windows/findfile.h" +/** Create an array of valid paths to search for resources. + * + * The idea is that all the complex path computation to find resources + * is performed here, once, rather than every time a resource is + * searched for. + */ +char ** +nsws_init_resource(const char *resource_path) +{ + char **pathv; /* resource path string vector */ + char **respath; /* resource paths vector */ + const char *lang = NULL; + char *winpath; + int pathi; + char *slsh; + + pathv = filepath_path_to_strvec(resource_path); + if (pathv == NULL) + return NULL; + + winpath = malloc(MAX_PATH); + GetModuleFileName(NULL, winpath, MAX_PATH); + slsh = strrchr(winpath, '\\'); + if (slsh != NULL) + *slsh=0; + strncat(winpath, "\\windows\\res", MAX_PATH); + + pathi = 0; + while (pathv[pathi] != NULL) + pathi++; + pathv[pathi] = winpath; + + + pathi = 0; + while (pathv[pathi] != NULL) { + LOG(("pathv[%d] = \"%s\"",pathi, pathv[pathi])); + pathi++; + } + + respath = filepath_generate(pathv, &lang); + + filepath_free_strvec(pathv); + + return respath; +} + static char *realpath(const char *path, char *resolved_path) { /* useless, but there we go */ -- cgit v1.2.3