gui_find_resource --> gui_get_resource_url.

svn path=/trunk/netsurf/; revision=12089
This commit is contained in:
Michael Drake 2011-03-17 11:57:09 +00:00
parent 66f6e9eff5
commit a70c32422a
11 changed files with 19 additions and 17 deletions

View File

@ -431,7 +431,7 @@ void ami_amiupdate(void)
/* end Amiupdate */
}
char* gui_find_resource(const char *filename)
char* gui_get_resource_url(const char *filename)
{
char path[1024];
char filename2[1024];

View File

@ -1049,7 +1049,7 @@ static inline void create_cursor(int flags, short mode, void * form, MFORM_EX *
}
}
char* gui_find_resource(const char *filename)
char* gui_get_resource_url(const char *filename)
{
return NULL;
}

View File

@ -422,7 +422,7 @@ static int32 bapp_thread(void *arg)
return 0;
}
char* gui_find_resource(const char *filename)
char* gui_get_resource_url(const char *filename)
{
BString u("rsrc:/");
u << filename;

View File

@ -50,7 +50,7 @@ NSString * const kAlwaysCloseMultipleTabs = @"AlwaysCloseMultipleTabs";
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
char* gui_find_resource(const char *filename)
char* gui_get_resource_url(const char *filename)
{
NSString *path = [[NSBundle mainBundle] pathForResource: [NSString stringWithUTF8String: filename] ofType: @""];
if (path == nil) return NULL;

View File

@ -177,7 +177,7 @@ fetch_resource_setup(struct fetch *fetchh,
url_get_components(url, &urlcomp);
ctx->redirect_url = gui_find_resource(urlcomp.path);
ctx->redirect_url = gui_get_resource_url(urlcomp.path);
if (ctx->redirect_url == NULL) {
ctx->handler = fetch_resource_notfound_handler;
} else {

View File

@ -48,6 +48,6 @@ void fetch_resource_register(void);
* \return A string containing the full URL of the target object or
* NULL if no suitable resource can be found.
*/
char* gui_find_resource(const char *filename);
char* gui_get_resource_url(const char *filename);
#endif

View File

@ -92,7 +92,7 @@ char *url_to_path(const char *url)
return respath;
}
char* gui_find_resource(const char *filename)
char* gui_get_resource_url(const char *filename)
{
char buf[PATH_MAX];
return path_to_url(filepath_sfind(respaths, buf, filename));

View File

@ -326,7 +326,7 @@ static void check_options(char **respath)
}
char* gui_find_resource(const char *filename)
char* gui_get_resource_url(const char *filename)
{
char buf[PATH_MAX];
return path_to_url(filepath_sfind(respaths, buf, filename));

View File

@ -72,7 +72,7 @@ void gui_quit(void)
gtk_fetch_filetype_fin();
}
char* gui_find_resource(const char *filename)
char* gui_get_resource_url(const char *filename)
{
char buf[PATH_MAX];
return path_to_url(filepath_sfind(respaths, buf, filename));

View File

@ -281,24 +281,26 @@ static void ro_msg_save_desktop(wimp_message *message);
static void ro_msg_window_info(wimp_message *message);
static void ro_gui_view_source_bounce(wimp_message *message);
char* gui_find_resource(const char *filename)
char* gui_get_resource_url(const char *filename)
{
/* Find max URL length */
size_t length = SLEN("file:///NetSurf:/Resources/") + SLEN("xx/") +
strlen(filename) + 1;
const char base_url[] = "file:///NetSurf:/Resources/";
size_t filename_len = strlen(filename);
/* Allocate memory for URL (freed by the core) */
/* Find max URL length */
size_t length = SLEN(base_url) + SLEN("xx/") + filename_len + 1;
/* Allocate memory for URL (will be owned and freed by the core) */
char *resource_url = malloc(length);
if (resource_url == NULL)
return NULL;
/* Insert base URL */
resource_url = strcpy(resource_url, "file:///NetSurf:/Resources/");
resource_url = strcpy(resource_url, base_url);
/* Add language directory to URL, for translated files */
/* TODO: handle non-en langauages
* handle non-html translated files */
if (strncmp(filename + strlen(filename) - 5, ".html", 5) == 0) {
if (strncmp(filename + filename_len - 5, ".html", 5) == 0) {
resource_url = strcat(resource_url, "en/");
}

View File

@ -2542,7 +2542,7 @@ void gui_quit(void)
LOG(("gui_quit"));
}
char* gui_find_resource(const char *filename)
char* gui_get_resource_url(const char *filename)
{
return NULL;
}