]> Pileus Git - grits/blobdiff - src/data/gis-http.c
Win32 port
[grits] / src / data / gis-http.c
index d01701342f9d4fc507d1e4e4844a6b4a9d8c0850..b5259e47108e15a92f0f95b44c24d4b19828a873 100644 (file)
@@ -125,7 +125,6 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
 {
        g_debug("GisHttp: fetch - %s... >> %s/%s  mode=%d",
                        uri, http->prefix, local, mode);
-
        gchar *path = _get_cache_path(http, local);
 
        /* Unlink the file if we're refreshing it */
@@ -141,7 +140,8 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
                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 = {
@@ -178,6 +178,7 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
                }
        }
 
+
        /* TODO: free everything.. */
        return path;
 }
@@ -219,7 +220,6 @@ GList *gis_http_available(GisHttp *http,
                g_free(path);
        }
 
-
        /* Add online files if online */
        if (index) {
                gchar tmp[16];
@@ -233,9 +233,9 @@ GList *gis_http_available(GisHttp *http,
                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