[Libosinfo] [osinfo-db-tools PATCH v4 2/3] import: Learn how to deal with URLs
Felipe Borges
felipe10borges at gmail.com
Fri Dec 7 14:23:04 UTC 2018
Hi, thanks for working on this!
On Fri, Dec 7, 2018 at 2:34 PM Fabiano Fidêncio <fidencio at redhat.com> wrote:
>
> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
> ---
> tools/osinfo-db-import.c | 90 ++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 86 insertions(+), 4 deletions(-)
>
> diff --git a/tools/osinfo-db-import.c b/tools/osinfo-db-import.c
> index 72f21ba..e4b7824 100644
> --- a/tools/osinfo-db-import.c
> +++ b/tools/osinfo-db-import.c
> @@ -134,6 +134,55 @@ static GFile *osinfo_db_import_get_file(GFile *target,
> return g_file_resolve_relative_path(target, tmp);
> }
>
> +static int
> +osinfo_db_import_download_file(const gchar *url,
> + gchar **source_file)
> +{
> + GFile *in = NULL;
> + GFile *out = NULL;
> + GError *err = NULL;
> + gchar *filename = NULL;
> + GFileCopyFlags flags = G_FILE_COPY_OVERWRITE | G_FILE_COPY_BACKUP;
> + int ret = -1;
> +
> + in = g_file_new_for_uri(url);
> + if (in == NULL)
> + return -1;
> +
> + filename = g_file_get_basename(in);
> + if (filename == NULL)
> + goto cleanup;
> +
> + *source_file = g_strdup_printf("%s/%s", g_get_user_cache_dir(), filename);
Any reason for not using "g_build_filename" here?
More information about the Libosinfo
mailing list