Rev 8425 | Rev 8839 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8425 | Rev 8697 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #define MEMSIZE 1024 * 40 |
1 | #define MEMSIZE 1024 * 40 |
2 | //Copyright 2020 by Leency |
2 | //Copyright 2020 - 2021 by Leency |
3 | #include "../lib/gui.h" |
3 | #include "../lib/gui.h" |
4 | #include "../lib/random.h" |
4 | #include "../lib/random.h" |
5 | #include "../lib/obj/box_lib.h" |
5 | #include "../lib/obj/box_lib.h" |
6 | #include "../lib/obj/http.h" |
6 | #include "../lib/obj/http.h" |
Line 179... | Line 179... | ||
179 | edit_box_set_text stdcall (#ed, #redirect_url); |
179 | edit_box_set_text stdcall (#ed, #redirect_url); |
180 | StopDownloading(); |
180 | StopDownloading(); |
181 | StartDownloading(); |
181 | StartDownloading(); |
182 | return; |
182 | return; |
183 | } |
183 | } |
184 | SaveFile(); |
184 | SaveFile(0); |
185 | if (exit_param) ExitProcess(); |
185 | if (exit_param) ExitProcess(); |
186 | StopDownloading(); |
186 | StopDownloading(); |
187 | DrawWindow(); |
187 | DrawWindow(); |
188 | } |
188 | } |
189 | } |
189 | } |
Line 190... | Line 190... | ||
190 | 190 | ||
191 | void SaveFile() |
191 | void SaveFile(int attempt) |
192 | { |
192 | { |
193 | int i; |
193 | int i, fi=0; |
194 | char notify_message[4296]; |
194 | char notify_message[4296]; |
Line 195... | Line 195... | ||
195 | char file_name[URL_SIZE+96]; |
195 | char file_name[URL_SIZE+96]; |
196 | 196 | ||
Line -... | Line 197... | ||
- | 197 | strcpy(#filepath, #save_dir); |
|
- | 198 | chrcat(#filepath, '/'); |
|
- | 199 | ||
- | 200 | if (attempt > 9) { |
|
- | 201 | notify("'Too many saving attempts' -E"); |
|
- | 202 | return; |
|
- | 203 | } |
|
- | 204 | ||
- | 205 | if (attempt > 0) { |
|
- | 206 | chrcat(#filepath, attempt+'0'); |
|
197 | strcpy(#filepath, #save_dir); |
207 | chrcat(#filepath, '_'); |
198 | chrcat(#filepath, '/'); |
208 | } |
199 | 209 | ||
200 | //Content-Disposition: attachment; filename="RealFootball_2018_Nokia_5800_EN_IGP_EU_TS_101.zip" |
210 | //Content-Disposition: attachment; filename="RealFootball_2018_Nokia_5800_EN_IGP_EU_TS_101.zip" |
201 | if (http.header_field("content-disposition", #file_name, sizeof(file_name))) { |
211 | if (http.header_field("content-disposition", #file_name, sizeof(file_name))) { |
Line 212... | Line 222... | ||
212 | strcat(#filepath, #file_name+strrchr(#file_name, '/')); |
222 | strcat(#filepath, #file_name+strrchr(#file_name, '/')); |
213 | } |
223 | } |
Line 214... | Line 224... | ||
214 | 224 | ||
Line -... | Line 225... | ||
- | 225 | for (i=0; i |
|
- | 226 | ||
- | 227 | while (file_exists(#filepath)) { |
|
- | 228 | SaveFile(attempt+1); |
|
- | 229 | return; |
|
215 | for (i=0; i |
230 | } |
216 | 231 | ||
217 | if (CreateFile(http.content_received, http.content_pointer, #filepath)==0) { |
232 | if (CreateFile(http.content_received, http.content_pointer, #filepath)==0) { |
218 | miniprintf(#notify_message, FILE_SAVED_AS, #filepath); |
233 | miniprintf(#notify_message, FILE_SAVED_AS, #filepath); |
219 | } else { |
234 | } else { |