X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=netinstall%2Fdownload.cc;fp=netinstall%2Fdownload.cc;h=3b6ad952067448fc48a463450252c2e76c45c111;hp=0000000000000000000000000000000000000000;hb=1ecbe603154527afa87c21523aedd8e3bda77c2f;hpb=131844b7560952b4f8e1cb8628d9115e0f2f29d2 diff --git a/netinstall/download.cc b/netinstall/download.cc new file mode 100644 index 0000000..3b6ad95 --- /dev/null +++ b/netinstall/download.cc @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2000, Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * A copy of the GNU General Public License can be found at + * http://www.gnu.org/ + * + * Written by DJ Delorie + * + */ + +/* The purpose of this file is to download all the files we need to + do the installation. */ + +#include +#include +#include + +#include "win32.h" + +#include "resource.h" +#include "msg.h" +#include "ini.h" +#include "dialog.h" +#include "concat.h" +#include "geturl.h" +#include "state.h" +#include "mkdir.h" +#include "log.h" + +#define pi (package[i].info[package[i].trust]) + +static int +download_one (char *name, int expected_size) +{ + char *local = name; + + struct stat s; + if (stat (local, &s) >= 0) + if (s.st_size == expected_size) + return 0; + + mkdir_p (0, local); + + if (get_url_to_file (concat (MIRROR_SITE, "/", name, 0), + concat (local, ".tmp", 0), + expected_size)) + { + note (IDS_DOWNLOAD_FAILED, name); + return 1; + } + else + { + stat (concat (local, ".tmp", 0), &s); + if (s.st_size == expected_size) + { + log (0, "Downloaded %s", local); + rename (concat (local, ".tmp", 0), local); + } + else + { + log (0, "Download %s wrong size (%d actual vs %d expected)", + local, s.st_size, expected_size); + note (IDS_DOWNLOAD_SHORT, local, s.st_size, expected_size); + return 1; + } + } + + return 0; +} + +void +do_download (HINSTANCE h) +{ + int i; + int errors = 0; + + for (i=0; i