mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +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
@ -312,31 +312,36 @@ gpgtar_extract (const char *filename, int decrypt)
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename)
|
if (opt.directory)
|
||||||
|
dirname = xtrystrdup (opt.directory);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
dirprefix = strrchr (filename, '/');
|
if (filename)
|
||||||
if (dirprefix)
|
{
|
||||||
dirprefix++;
|
dirprefix = strrchr (filename, '/');
|
||||||
else
|
if (dirprefix)
|
||||||
dirprefix = filename;
|
dirprefix++;
|
||||||
}
|
else
|
||||||
else if (opt.filename)
|
dirprefix = filename;
|
||||||
{
|
}
|
||||||
dirprefix = strrchr (opt.filename, '/');
|
else if (opt.filename)
|
||||||
if (dirprefix)
|
{
|
||||||
dirprefix++;
|
dirprefix = strrchr (opt.filename, '/');
|
||||||
else
|
if (dirprefix)
|
||||||
dirprefix = opt.filename;
|
dirprefix++;
|
||||||
}
|
else
|
||||||
|
dirprefix = opt.filename;
|
||||||
|
}
|
||||||
|
|
||||||
if (!dirprefix || !*dirprefix)
|
if (!dirprefix || !*dirprefix)
|
||||||
dirprefix = "GPGARCH";
|
dirprefix = "GPGARCH";
|
||||||
|
|
||||||
dirname = create_directory (dirprefix);
|
dirname = create_directory (dirprefix);
|
||||||
if (!dirname)
|
if (!dirname)
|
||||||
{
|
{
|
||||||
err = gpg_error (GPG_ERR_GENERAL);
|
err = gpg_error (GPG_ERR_GENERAL);
|
||||||
goto leave;
|
goto leave;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt.verbose)
|
if (opt.verbose)
|
||||||
|
@ -58,6 +58,7 @@ enum cmd_and_opt_values
|
|||||||
oRecipient = 'r',
|
oRecipient = 'r',
|
||||||
oUser = 'u',
|
oUser = 'u',
|
||||||
oOutput = 'o',
|
oOutput = 'o',
|
||||||
|
oDirectory = 'C',
|
||||||
oQuiet = 'q',
|
oQuiet = 'q',
|
||||||
oVerbose = 'v',
|
oVerbose = 'v',
|
||||||
oFilesFrom = 'T',
|
oFilesFrom = 'T',
|
||||||
@ -89,6 +90,8 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
ARGPARSE_s_s (oUser, "local-user",
|
ARGPARSE_s_s (oUser, "local-user",
|
||||||
N_("|USER-ID|use USER-ID to sign or decrypt")),
|
N_("|USER-ID|use USER-ID to sign or decrypt")),
|
||||||
ARGPARSE_s_s (oOutput, "output", N_("|FILE|write output to FILE")),
|
ARGPARSE_s_s (oOutput, "output", N_("|FILE|write output to FILE")),
|
||||||
|
ARGPARSE_s_s (oDirectory, "directory",
|
||||||
|
N_("|DIRECTORY|extract files into DIRECTORY")),
|
||||||
ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")),
|
ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")),
|
||||||
ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")),
|
ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")),
|
||||||
ARGPARSE_s_s (oGpgProgram, "gpg", "@"),
|
ARGPARSE_s_s (oGpgProgram, "gpg", "@"),
|
||||||
@ -194,6 +197,7 @@ main (int argc, char **argv)
|
|||||||
switch (pargs.r_opt)
|
switch (pargs.r_opt)
|
||||||
{
|
{
|
||||||
case oOutput: opt.outfile = pargs.r.ret_str; break;
|
case oOutput: opt.outfile = pargs.r.ret_str; break;
|
||||||
|
case oDirectory: opt.directory = pargs.r.ret_str; break;
|
||||||
case oSetFilename: opt.filename = pargs.r.ret_str; break;
|
case oSetFilename: opt.filename = pargs.r.ret_str; break;
|
||||||
case oQuiet: opt.quiet = 1; break;
|
case oQuiet: opt.quiet = 1; break;
|
||||||
case oVerbose: opt.verbose++; break;
|
case oVerbose: opt.verbose++; break;
|
||||||
|
@ -35,6 +35,7 @@ struct
|
|||||||
const char *user;
|
const char *user;
|
||||||
int symmetric;
|
int symmetric;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
|
const char *directory;
|
||||||
} opt;
|
} opt;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user