]> cygwin.com Git - cygwin-apps/setup.git/blame - download.cc
* Makefile.in: (%.o: %.rc): Specify --include-dir $(w32api_include).
[cygwin-apps/setup.git] / download.cc
CommitLineData
23c9e63c
DD
1/*
2 * Copyright (c) 2000, Red Hat, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by DJ Delorie <dj@cygnus.com>
13 *
14 */
15
16/* The purpose of this file is to download all the files we need to
17 do the installation. */
18
8507f105
DD
19static char *cvsid = "\n%%% $Id$\n";
20
23c9e63c
DD
21#include "win32.h"
22
23#include <stdio.h>
24#include <sys/types.h>
25#include <sys/stat.h>
26
27#include "resource.h"
28#include "msg.h"
29#include "ini.h"
30#include "dialog.h"
31#include "concat.h"
32#include "geturl.h"
33#include "state.h"
34#include "mkdir.h"
89b1a15b 35#include "log.h"
23c9e63c
DD
36
37#define pi (package[i].info[package[i].trust])
38
3b9077d4
DD
39static int
40download_one (char *name, int expected_size)
41{
42 char *local = name;
43 int errors = 0;
44
45 struct stat s;
46 if (stat (local, &s) >= 0)
47 if (s.st_size == expected_size)
48 return 0;
49
50 mkdir_p (0, local);
51
52 if (get_url_to_file (concat (MIRROR_SITE, "/", name, 0),
53 concat (local, ".tmp", 0),
54 expected_size))
55 {
56 note (IDS_DOWNLOAD_FAILED, name);
57 return 1;
58 }
59 else
60 {
61 stat (concat (local, ".tmp", 0), &s);
62 if (s.st_size == expected_size)
63 {
64 log (0, "Downloaded %s", local);
65 rename (concat (local, ".tmp", 0), local);
66 }
67 else
68 {
69 log (0, "Download %s wrong size (%d actual vs %d expected)",
70 local, s.st_size, expected_size);
71 note (IDS_DOWNLOAD_SHORT, local, s.st_size, expected_size);
72 return 1;
73 }
74 }
75
76 return 0;
77}
78
23c9e63c
DD
79void
80do_download (HINSTANCE h)
81{
82 int i;
2a1a01e0 83 int errors = 0;
23c9e63c
DD
84
85 for (i=0; i<npackages; i++)
4a83b7b0 86 if (package[i].action == ACTION_NEW || package[i].action == ACTION_UPGRADE)
23c9e63c 87 {
3b9077d4
DD
88 int e = download_one (pi.install, pi.install_size);
89 if (package[i].srcaction == SRCACTION_YES && pi.source)
90 e += download_one (pi.source, pi.source_size);
91 errors += e;
92 if (e)
93 package[i].action = ACTION_ERROR;
23c9e63c
DD
94 }
95
96 dismiss_url_status_dialog ();
bf1d5889 97
2a1a01e0
DD
98 if (errors)
99 {
100 if (yesno (IDS_DOWNLOAD_INCOMPLETE) == IDYES)
101 {
102 next_dialog = IDD_SITE;
103 return;
104 }
105 }
106
bf1d5889
DD
107 if (source == IDC_SOURCE_DOWNLOAD)
108 {
2a1a01e0
DD
109 if (errors)
110 exit_msg = IDS_DOWNLOAD_INCOMPLETE;
111 else
112 exit_msg = IDS_DOWNLOAD_COMPLETE;
bf1d5889
DD
113 next_dialog = 0;
114 }
115 else
116 next_dialog = IDD_S_INSTALL;
23c9e63c 117}
This page took 0.035531 seconds and 5 git commands to generate.