glib network connection example

倖福魔咒の 提交于 2019-12-05 14:56:14
Yasushi Shoji

How about like this? There is similar question at Fetch a file from web: in GTK using C

#include <gio/gio.h>

int main()
{
        const gchar *uri = "https://stackoverflow.com/questions/5758770/";
        GFile *in;
        GFile *out;
        GError *error = NULL;
        gboolean ret;

        g_type_init();

        in = g_file_new_for_uri(uri);
        out = g_file_new_for_path("/tmp/a");

        ret = g_file_copy(in, out, G_FILE_COPY_OVERWRITE,
                          NULL, NULL, NULL, &error);
        if (!ret)
                g_message("%s", error->message);

        return 0;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!