mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-11-24 01:39:35 +03:00
WebView Downloader: if file already exist, save the file with a new name
git-svn-id: svn://kolibrios.org@8697 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
99dce7afaf
commit
b930c6f5f7
@ -1,5 +1,5 @@
|
||||
#define MEMSIZE 1024 * 40
|
||||
//Copyright 2020 by Leency
|
||||
//Copyright 2020 - 2021 by Leency
|
||||
#include "../lib/gui.h"
|
||||
#include "../lib/random.h"
|
||||
#include "../lib/obj/box_lib.h"
|
||||
@ -181,22 +181,32 @@ void MonitorProgress()
|
||||
StartDownloading();
|
||||
return;
|
||||
}
|
||||
SaveFile();
|
||||
SaveFile(0);
|
||||
if (exit_param) ExitProcess();
|
||||
StopDownloading();
|
||||
DrawWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void SaveFile()
|
||||
void SaveFile(int attempt)
|
||||
{
|
||||
int i;
|
||||
int i, fi=0;
|
||||
char notify_message[4296];
|
||||
char file_name[URL_SIZE+96];
|
||||
|
||||
strcpy(#filepath, #save_dir);
|
||||
chrcat(#filepath, '/');
|
||||
|
||||
if (attempt > 9) {
|
||||
notify("'Too many saving attempts' -E");
|
||||
return;
|
||||
}
|
||||
|
||||
if (attempt > 0) {
|
||||
chrcat(#filepath, attempt+'0');
|
||||
chrcat(#filepath, '_');
|
||||
}
|
||||
|
||||
//Content-Disposition: attachment; filename="RealFootball_2018_Nokia_5800_EN_IGP_EU_TS_101.zip"
|
||||
if (http.header_field("content-disposition", #file_name, sizeof(file_name))) {
|
||||
if (EDX = strstr(#file_name,"filename=\"")) {
|
||||
@ -214,6 +224,11 @@ void SaveFile()
|
||||
|
||||
for (i=0; i<strlen(#filepath); i++) if(filepath[i]==':')||(filepath[i]=='?')filepath[i]='-';
|
||||
|
||||
while (file_exists(#filepath)) {
|
||||
SaveFile(attempt+1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (CreateFile(http.content_received, http.content_pointer, #filepath)==0) {
|
||||
miniprintf(#notify_message, FILE_SAVED_AS, #filepath);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user