mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
tools/gpgtar: Handle '--directory' argument.
* tools/gpgtar-extract.c (gpgtar_extract): Only generate a directory name if none is given via arguments. * tools/gpgtar.c (enum cmd_and_opt_values): New constant. (opts): Add argument. (main): Parse argument. * tools/gpgtar.h (opt): New field 'directory'. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
89e104eb38
commit
127aba9a4d
3 changed files with 32 additions and 22 deletions
|
@ -312,31 +312,36 @@ gpgtar_extract (const char *filename, int decrypt)
|
|||
goto leave;
|
||||
}
|
||||
|
||||
if (filename)
|
||||
if (opt.directory)
|
||||
dirname = xtrystrdup (opt.directory);
|
||||
else
|
||||
{
|
||||
dirprefix = strrchr (filename, '/');
|
||||
if (dirprefix)
|
||||
dirprefix++;
|
||||
else
|
||||
dirprefix = filename;
|
||||
}
|
||||
else if (opt.filename)
|
||||
{
|
||||
dirprefix = strrchr (opt.filename, '/');
|
||||
if (dirprefix)
|
||||
dirprefix++;
|
||||
else
|
||||
dirprefix = opt.filename;
|
||||
}
|
||||
if (filename)
|
||||
{
|
||||
dirprefix = strrchr (filename, '/');
|
||||
if (dirprefix)
|
||||
dirprefix++;
|
||||
else
|
||||
dirprefix = filename;
|
||||
}
|
||||
else if (opt.filename)
|
||||
{
|
||||
dirprefix = strrchr (opt.filename, '/');
|
||||
if (dirprefix)
|
||||
dirprefix++;
|
||||
else
|
||||
dirprefix = opt.filename;
|
||||
}
|
||||
|
||||
if (!dirprefix || !*dirprefix)
|
||||
dirprefix = "GPGARCH";
|
||||
if (!dirprefix || !*dirprefix)
|
||||
dirprefix = "GPGARCH";
|
||||
|
||||
dirname = create_directory (dirprefix);
|
||||
if (!dirname)
|
||||
{
|
||||
err = gpg_error (GPG_ERR_GENERAL);
|
||||
goto leave;
|
||||
dirname = create_directory (dirprefix);
|
||||
if (!dirname)
|
||||
{
|
||||
err = gpg_error (GPG_ERR_GENERAL);
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
|
||||
if (opt.verbose)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue