]>
Commit | Line | Data |
---|---|---|
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 | ||
19 | #include "win32.h" | |
20 | ||
21 | #include <stdio.h> | |
22 | #include <sys/types.h> | |
23 | #include <sys/stat.h> | |
24 | ||
25 | #include "resource.h" | |
26 | #include "msg.h" | |
27 | #include "ini.h" | |
28 | #include "dialog.h" | |
29 | #include "concat.h" | |
30 | #include "geturl.h" | |
31 | #include "state.h" | |
32 | #include "mkdir.h" | |
33 | ||
34 | #define pi (package[i].info[package[i].trust]) | |
35 | ||
36 | void | |
37 | do_download (HINSTANCE h) | |
38 | { | |
39 | int i; | |
23c9e63c DD |
40 | |
41 | for (i=0; i<npackages; i++) | |
42 | if (package[i].action != ACTION_SAME) | |
43 | { | |
44 | char *local = pi.install; | |
45 | ||
46 | struct stat s; | |
47 | if (stat (local, &s) >= 0) | |
48 | if (s.st_size == pi.install_size) | |
49 | continue; | |
50 | ||
51 | mkdir_p (0, local); | |
52 | ||
53 | if (get_url_to_file (concat (MIRROR_SITE, "/", pi.install, 0), | |
54 | concat (local, ".tmp", 0), | |
55 | pi.install_size)) | |
56 | { | |
57 | package[i].action = ACTION_ERROR; | |
58 | continue; | |
59 | } | |
60 | else | |
61 | { | |
62 | stat (concat (local, ".tmp", 0), &s); | |
63 | if (s.st_size == pi.install_size) | |
64 | { | |
65 | rename (concat (local, ".tmp", 0), local); | |
66 | } | |
67 | else | |
68 | { | |
69 | note (IDS_DOWNLOAD_SHORT, local, s.st_size, pi.install_size); | |
70 | package[i].action = ACTION_ERROR; | |
71 | } | |
72 | } | |
73 | } | |
74 | ||
75 | dismiss_url_status_dialog (); | |
bf1d5889 DD |
76 | |
77 | if (source == IDC_SOURCE_DOWNLOAD) | |
78 | { | |
f57c332f | 79 | exit_msg = IDS_DOWNLOAD_COMPLETE; |
bf1d5889 DD |
80 | next_dialog = 0; |
81 | } | |
82 | else | |
83 | next_dialog = IDD_S_INSTALL; | |
23c9e63c | 84 | } |