Show existing file size when file already exists on download

svn path=/trunk/netsurf/; revision=12618
mmu_man/xf86keys
Chris Young 14 years ago
parent 9cd5974868
commit 7f6b694732

@ -408,6 +408,11 @@ amiDownload:%ld von %ld Bytes heruntergeladen
amiDownloadU:%ld Bytes heruntergeladen
amiDownloadComplete:NetSurf: Download vollständig
# Requesters
#
amiSizeExisting:Existing file size:
amiSizeNew:New file size:
# GTK download window tokens
#
# This section contains tokens which are used in the gtk

@ -412,6 +412,11 @@ amiDownload:%ld of %ld bytes downloaded
amiDownloadU:%ld bytes downloaded
amiDownloadComplete:NetSurf: Download completed
# Requesters
#
amiSizeExisting:Existing file size:
amiSizeNew:New file size:
# GTK download window tokens
#
# This section contains tokens which are used in the gtk

@ -408,6 +408,11 @@ amiDownload:%ld of %ld bytes downloaded
amiDownloadU:%ld bytes downloaded
amiDownloadComplete:NetSurf: Download completed
# Requesters
#
amiSizeExisting:Existing file size:
amiSizeNew:New file size:
# GTK download window tokens
#
# This section contains tokens which are used in the gtk

@ -412,6 +412,11 @@ amiDownload:%ld di %ld byte scaricati
amiDownloadU:%ld byte scaricati
amiDownloadComplete:NetSurf: Download completato
# Requesters
#
amiSizeExisting:Existing file size:
amiSizeNew:New file size:
# GTK download window tokens
#
# This section contains tokens which are used in the gtk

@ -408,6 +408,11 @@ amiDownload:%ld of %ld bytes downloaded
amiDownloadU:%ld bytes downloaded
amiDownloadComplete:NetSurf: Download completed
# Requesters
#
amiSizeExisting:Existing file size:
amiSizeNew:New file size:
# GTK download window tokens
#
# This section contains tokens which are used in the gtk

@ -33,6 +33,7 @@
#include <datatypes/pictureclass.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/utility.h>
#include "utils/messages.h"
/**
@ -138,7 +139,7 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags)
int err = 0;
Object *dto = NULL;
if(!ami_download_check_overwrite(path, NULL)) return false;
if(!ami_download_check_overwrite(path, NULL, 0)) return false;
if(dto = ami_datatype_object_from_bitmap(bitmap))
{

@ -517,7 +517,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
AddPart(fname,savereq->fr_File,1024);
ami_update_pointer(gwin->win,GUI_POINTER_WAIT);
if(ami_download_check_overwrite(fname, gwin->win))
if(ami_download_check_overwrite(fname, gwin->win, 0))
{
if(fh = FOpen(fname,MODE_NEWFILE,0))
{

@ -102,7 +102,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
{
strlcpy(dw->fname, savereq->fr_Drawer, 1024);
AddPart((STRPTR)&dw->fname,savereq->fr_File,1024);
if(!ami_download_check_overwrite(dw->fname, gui->shared->win))
if(!ami_download_check_overwrite(dw->fname, gui->shared->win, total_size))
{
FreeVec(dw);
return NULL;
@ -327,7 +327,7 @@ gui_window_save_link(struct gui_window *g, const char *url, const char *title)
AddPart(fname,savereq->fr_File,1024);
ami_update_pointer(g->shared->win,GUI_POINTER_WAIT);
if(ami_download_check_overwrite(fname, g->shared->win))
if(ami_download_check_overwrite(fname, g->shared->win, 0))
{
if(fh = FOpen(fname,MODE_NEWFILE,0))
{
@ -356,11 +356,14 @@ gui_window_save_link(struct gui_window *g, const char *url, const char *title)
}
}
BOOL ami_download_check_overwrite(const char *file, struct Window *win)
BOOL ami_download_check_overwrite(const char *file, struct Window *win, ULONG size)
{
/* Return TRUE if file can be (over-)written */
int res = 0;
BPTR lock = 0;
BPTR fh = 0;
int64 oldsize = 0;
char *overwritetext;
if(option_ask_overwrite == false) return TRUE;
@ -368,9 +371,23 @@ BOOL ami_download_check_overwrite(const char *file, struct Window *win)
if(lock)
{
UnLock(lock);
if(size) {
if(fh = OpenFromLock(lock)) {
oldsize = GetFileSize(fh);
Close(fh);
}
overwritetext = ASPrintf("%s\n\n%s %lu %s\n%s %lu %s",
messages_get("OverwriteFile"),
messages_get("amiSizeExisting"), (ULONG)oldsize, messages_get("Bytes"),
messages_get("amiSizeNew"), size, messages_get("Bytes"));
} else {
UnLock(lock);
overwritetext = ASPrintf(messages_get("OverwriteFile"));
}
char *utf8text = ami_utf8_easy(overwritetext);
FreeVec(overwritetext);
char *utf8text = ami_utf8_easy(messages_get("OverwriteFile"));
char *utf8gadget1 = ami_utf8_easy(messages_get("DontReplace"));
char *utf8gadget2 = ami_utf8_easy(messages_get("Replace"));
char *utf8gadgets = ASPrintf("%s|%s", utf8gadget1, utf8gadget2);

@ -35,5 +35,5 @@ struct dlnode
void ami_download_window_abort(struct gui_download_window *dw);
BOOL ami_download_window_event(struct gui_download_window *dw);
void ami_free_download_list(struct List *dllist);
BOOL ami_download_check_overwrite(const char *file, struct Window *win);
BOOL ami_download_check_overwrite(const char *file, struct Window *win, ULONG size);
#endif

@ -156,7 +156,7 @@ void ami_drag_save(struct Window *win)
BPTR fh = 0;
AddPart(path, content_get_title(c), 1024);
if(!ami_download_check_overwrite(path, win))
if(!ami_download_check_overwrite(path, win, 0))
break;
if(fh = FOpen(path,MODE_NEWFILE,0))
@ -172,7 +172,7 @@ void ami_drag_save(struct Window *win)
case GUI_SAVE_TEXT_SELECTION: // selection
AddPart(path,"netsurf_text_file",1024);
if(!ami_download_check_overwrite(path, win))
if(!ami_download_check_overwrite(path, win, 0))
break;
selection_save_text((struct selection *)drag_save_data,path);
break;
@ -183,7 +183,7 @@ void ami_drag_save(struct Window *win)
BPTR lock = 0;
AddPart(path, content_get_title(c), 1024);
if(!ami_download_check_overwrite(path, win))
if(!ami_download_check_overwrite(path, win, 0))
break;
if(lock = CreateDir(path))

@ -135,6 +135,8 @@ void ami_get_msg(void);
void ami_close_all_tabs(struct gui_window_2 *gwin);
void ami_quit_netsurf(void);
void ami_do_redraw(struct gui_window_2 *g);
void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw,
int x0, int y0, int x1, int y1);
STRPTR ami_locale_langs(void);
int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie);
struct box *ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y);

@ -308,7 +308,7 @@ bool ami_save_svg(struct hlcache_handle *c,char *filename)
const char *source_data;
ULONG source_size;
if(!ami_download_check_overwrite(filename, NULL)) return false;
if(!ami_download_check_overwrite(filename, NULL, 0)) return false;
if(iffh = AllocIFF())
{

@ -535,7 +535,7 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item)
AddPart(fname,savereq->fr_File,1024);
ami_update_pointer(gwin->win,GUI_POINTER_WAIT);
if(ami_download_check_overwrite(fname, gwin->win))
if(ami_download_check_overwrite(fname, gwin->win, 0))
{
if(fh = FOpen(fname,MODE_NEWFILE,0))
{
@ -561,7 +561,7 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item)
AddPart(fname,savereq->fr_File,1024);
ami_update_pointer(gwin->win,GUI_POINTER_WAIT);
if(ami_download_check_overwrite(fname, gwin->win))
if(ami_download_check_overwrite(fname, gwin->win, 0))
{
save_as_text(gwin->bw->current_content,fname);
SetComment(fname,content_get_url(gwin->bw->current_content));
@ -580,7 +580,7 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item)
strlcpy(fname,savereq->fr_Drawer,1024);
AddPart(fname,savereq->fr_File,1024);
ami_update_pointer(gwin->win,GUI_POINTER_WAIT);
if(ami_download_check_overwrite(fname, gwin->win))
if(ami_download_check_overwrite(fname, gwin->win, 0))
{
if(lock = CreateDir(fname))
{

@ -30,7 +30,7 @@ void ami_utf8_free(char *ptr)
if(ptr) free(ptr);
}
char *ami_utf8_easy(char *string)
char *ami_utf8_easy(const char *string)
{
char *localtext;
@ -44,7 +44,7 @@ char *ami_utf8_easy(char *string)
}
}
char *ami_to_utf8_easy(char *string)
char *ami_to_utf8_easy(const char *string)
{
char *localtext;

Loading…
Cancel
Save