aboutsummaryrefslogtreecommitdiffstats
path: root/g10/openfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'g10/openfile.c')
-rw-r--r--g10/openfile.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/g10/openfile.c b/g10/openfile.c
index be186bd81..12a232a19 100644
--- a/g10/openfile.c
+++ b/g10/openfile.c
@@ -369,36 +369,18 @@ open_sigfile (const char *sigfilename, progress_filter_context_t *pfx)
}
+/* Create the directory only if the supplied directory name is the
+ same as the default one. This way we avoid to create arbitrary
+ directories when a non-default home directory is used. To cope
+ with HOME, we do compare only the suffix if we see that the default
+ homedir does start with a tilde. */
void
try_make_homedir (const char *fname)
{
- const char *defhome = standard_homedir ();
-
- /* Create the directory only if the supplied directory name is the
- same as the default one. This way we avoid to create arbitrary
- directories when a non-default home directory is used. To cope
- with HOME, we do compare only the suffix if we see that the
- default homedir does start with a tilde. */
if ( opt.dry_run || opt.no_homedir_creation )
return;
- if (
-#ifdef HAVE_W32_SYSTEM
- ( !compare_filenames (fname, defhome) )
-#else
- ( *defhome == '~'
- && (strlen(fname) >= strlen (defhome+1)
- && !strcmp(fname+strlen(fname)-strlen(defhome+1), defhome+1 ) ))
- || (*defhome != '~' && !compare_filenames( fname, defhome ) )
-#endif
- )
- {
- if (gnupg_mkdir (fname, "-rwx"))
- log_fatal ( _("can't create directory '%s': %s\n"),
- fname, strerror(errno) );
- else if (!opt.quiet )
- log_info ( _("directory '%s' created\n"), fname );
- }
+ gnupg_maybe_make_homedir (fname, opt.quiet);
}