mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Allow to enter an alternate filename
This commit is contained in:
parent
ec742b7f58
commit
424f5d6d93
8 changed files with 55 additions and 29 deletions
|
@ -1,3 +1,10 @@
|
|||
2001-03-29 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* openfile.c (ask_outfile_name): Trim spaces.
|
||||
(open_outfile): Allow to enter an alternate filename. Thanks to
|
||||
Stefan Bellon.
|
||||
* plaintext.c (handle_plaintext): Ditto.
|
||||
|
||||
2001-03-28 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* mainproc.c (do_check_sig): Allow direct key and subkey
|
||||
|
|
|
@ -155,6 +155,8 @@ ask_outfile_name( const char *name, size_t namelen )
|
|||
fname = defname; defname = NULL;
|
||||
}
|
||||
m_free(defname);
|
||||
if (fname)
|
||||
trim_spaces (fname);
|
||||
return fname;
|
||||
}
|
||||
|
||||
|
@ -221,7 +223,19 @@ open_outfile( const char *iname, int mode, IOBUF *a )
|
|||
name = buf;
|
||||
}
|
||||
|
||||
if( overwrite_filep( name ) ) {
|
||||
rc = 0;
|
||||
while( !overwrite_filep (name) ) {
|
||||
char *tmp = ask_outfile_name (NULL, 0);
|
||||
if ( !tmp || !*tmp ) {
|
||||
m_free (tmp);
|
||||
rc = G10ERR_FILE_EXISTS;
|
||||
break;
|
||||
}
|
||||
m_free (buf);
|
||||
name = buf = tmp;
|
||||
}
|
||||
|
||||
if( !rc ) {
|
||||
if( !(*a = iobuf_create( name )) ) {
|
||||
log_error(_("%s: can't create: %s\n"), name, strerror(errno) );
|
||||
rc = G10ERR_CREATE_FILE;
|
||||
|
@ -229,8 +243,6 @@ open_outfile( const char *iname, int mode, IOBUF *a )
|
|||
else if( opt.verbose )
|
||||
log_info(_("writing to `%s'\n"), name );
|
||||
}
|
||||
else
|
||||
rc = G10ERR_FILE_EXISTS;
|
||||
m_free(buf);
|
||||
}
|
||||
return rc;
|
||||
|
|
|
@ -89,9 +89,17 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
|
|||
setmode ( fileno(fp) , O_BINARY );
|
||||
#endif
|
||||
}
|
||||
else if( !overwrite_filep( fname ) ) {
|
||||
rc = G10ERR_CREATE_FILE;
|
||||
goto leave;
|
||||
else {
|
||||
while( !overwrite_filep (fname) ) {
|
||||
char *tmp = ask_outfile_name (NULL, 0);
|
||||
if ( !tmp || !*tmp ) {
|
||||
m_free (tmp);
|
||||
rc = G10ERR_CREATE_FILE;
|
||||
goto leave;
|
||||
}
|
||||
m_free (fname);
|
||||
fname = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
if( fp || nooutput )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue