aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog7
-rw-r--r--g10/openfile.c18
-rw-r--r--g10/plaintext.c14
3 files changed, 33 insertions, 6 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index caad560e5..dedaf7e50 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,10 @@
+2001-03-29 Werner Koch <[email protected]>
+
+ * 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 <[email protected]>
* mainproc.c (do_check_sig): Allow direct key and subkey
diff --git a/g10/openfile.c b/g10/openfile.c
index 74050fee6..79c99785a 100644
--- a/g10/openfile.c
+++ b/g10/openfile.c
@@ -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;
diff --git a/g10/plaintext.c b/g10/plaintext.c
index 5820af6c6..f883f4a73 100644
--- a/g10/plaintext.c
+++ b/g10/plaintext.c
@@ -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 )