gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
GisCacheType mode, GisChunkCallback callback, gpointer user_data)
{
- g_debug("GisHttp: fetch - %s... >> %s/%s mode=%d",
- uri, http->prefix, local, mode);
-
+ g_debug("GisHttp: fetch - %s mode=%d", local, mode);
gchar *path = _get_cache_path(http, local);
/* Unlink the file if we're refreshing it */
gchar *part = path;
if (!g_file_test(path, G_FILE_TEST_EXISTS))
part = g_strdup_printf("%s.part", path);
- FILE *fp = fopen_p(part, "a");
+ FILE *fp = fopen_p(part, "ab");
+ fseek(fp, 0, SEEK_END); // "a" is broken on Windows, twice
/* Make temp data */
struct _CacheInfo info = {
}
}
+
/* TODO: free everything.. */
return path;
}
if (g_regex_match(filter_re, file, 0, NULL))
files = g_list_prepend(files, g_strdup(file));
g_free(path);
+ g_dir_close(dir);
}
-
/* Add online files if online */
if (index) {
gchar tmp[16];
GRegex *extract_re = g_regex_new(
extract ?: "href=\"([^\"]*)\"", 0, 0, NULL);
GMatchInfo *info;
- g_regex_match(filter_re, html, 0, &info);
+ g_regex_match(extract_re, html, 0, &info);
while (g_match_info_matches(info)) {
- gchar *file = g_match_info_fetch(info, 0);
+ gchar *file = g_match_info_fetch(info, 1);
if (g_regex_match(filter_re, file, 0, NULL))
files = g_list_prepend(files, file);
else
g_match_info_next(info, NULL);
}
+ g_regex_unref(extract_re);
g_match_info_free(info);
g_unlink(path);
g_free(path);
g_free(html);
}
+ g_regex_unref(filter_re);
+
return files;
}