From b930c6f5f7658781a291dfd39a4c614962d229a9 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Tue, 27 Apr 2021 17:56:49 +0000 Subject: [PATCH] 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 --- programs/cmm/downloader/dl.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/programs/cmm/downloader/dl.c b/programs/cmm/downloader/dl.c index f87e55be43..74d6bf8795 100644 --- a/programs/cmm/downloader/dl.c +++ b/programs/cmm/downloader/dl.c @@ -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