mothra: ask user for filename on save, override existing file

front
cinap_lenrek 2011-10-31 20:08:43 +01:00
parent 0f382bbf92
commit a5169a4834
1 changed files with 13 additions and 15 deletions

View File

@ -535,7 +535,7 @@ void save(int ifd, char *name){
message("save: %s: %r", name); message("save: %s: %r", name);
return; return;
} }
ofd=create(name, OEXCL|OWRITE, 0666); ofd=create(name, OWRITE, 0666);
if(ofd < 0){ if(ofd < 0){
message("save: %s: %r", name); message("save: %s: %r", name);
return; return;
@ -684,11 +684,13 @@ void docmd(Panel *p, char *s){
message("no url selected"); message("no url selected");
break; break;
} }
if(s==0 || *s=='\0')
s = urltofile(selection);
if(s==0 || *s=='\0'){ if(s==0 || *s=='\0'){
message("Usage: s file"); static char buf[NNAME];
snprint(buf, sizeof(buf), "%s", urltofile(selection));
if(eenter("Save to", buf, sizeof(buf), &mouse) <= 0)
break; break;
s = buf;
} }
save(urlopen(selection, GET, 0), s); save(urlopen(selection, GET, 0), s);
break; break;
@ -961,7 +963,7 @@ void freeurl(Url *u){
*/ */
void geturl(char *urlname, int method, char *body, int plumb, int map){ void geturl(char *urlname, int method, char *body, int plumb, int map){
int i, fd, typ; int i, fd, typ;
char *file, cmd[NNAME]; char cmd[NNAME];
int pfd[2]; int pfd[2];
Www *w; Www *w;
@ -1002,16 +1004,12 @@ void geturl(char *urlname, int method, char *body, int plumb, int map){
close(fd); close(fd);
break; break;
} }
file = urltofile(selection); snprint(cmd, sizeof(cmd), "%s", urltofile(selection));
if(!mothmode){ if(eenter("Save to", cmd, sizeof(cmd), &mouse) <= 0){
message("save to '%s' ?", file);
if(!confirm(1)){
message(mothra);
close(fd); close(fd);
break; break;
} }
} save(fd, cmd);
save(fd, file);
break; break;
case HTML: case HTML:
fd = pipeline("/bin/uhtml", fd); fd = pipeline("/bin/uhtml", fd);