mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-10-05 01:56:30 +00:00
Added -l option to bsatool.
This commit is contained in:
parent
2f13de8e2c
commit
650f33811d
4 changed files with 34 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
||||||
#include "bsatool_cmd.h"
|
#include "bsatool_cmd.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
|
@ -73,7 +74,17 @@ int main(int argc, char** argv)
|
||||||
// List all files
|
// List all files
|
||||||
const BSAFile::FileList &files = bsa.getList();
|
const BSAFile::FileList &files = bsa.getList();
|
||||||
for(int i=0; i<files.size(); i++)
|
for(int i=0; i<files.size(); i++)
|
||||||
cout << files[i].name << endl;
|
{
|
||||||
|
if(info.long_given)
|
||||||
|
{
|
||||||
|
// Long format
|
||||||
|
cout << setw(50) << left << files[i].name;
|
||||||
|
cout << setw(8) << left << dec << files[i].fileSize;
|
||||||
|
cout << "@ 0x" << hex << files[i].offset << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cout << files[i].name << endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Done!
|
// Done!
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -6,5 +6,6 @@ purpose "Inspect and extract files from Bethesda BSA archives"
|
||||||
args "--unamed-opts=BSA-FILE -F bsatool_cmd -G"
|
args "--unamed-opts=BSA-FILE -F bsatool_cmd -G"
|
||||||
|
|
||||||
option "extract" x "Extract file from archive" string optional
|
option "extract" x "Extract file from archive" string optional
|
||||||
|
option "long" l "Include extra information in archive listing" optional
|
||||||
|
|
||||||
text "\nIf no option is given, the default action is to list all files in the archive."
|
text "\nIf no option is given, the default action is to list all files in the archive."
|
||||||
|
|
|
@ -30,6 +30,7 @@ const char *gengetopt_args_info_help[] = {
|
||||||
" -h, --help Print help and exit",
|
" -h, --help Print help and exit",
|
||||||
" -V, --version Print version and exit",
|
" -V, --version Print version and exit",
|
||||||
" -x, --extract=STRING Extract file from archive",
|
" -x, --extract=STRING Extract file from archive",
|
||||||
|
" -l, --long Include extra information in archive listing",
|
||||||
"\nIf no option is given, the default action is to list all files in the archive.",
|
"\nIf no option is given, the default action is to list all files in the archive.",
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
@ -57,6 +58,7 @@ void clear_given (struct gengetopt_args_info *args_info)
|
||||||
args_info->help_given = 0 ;
|
args_info->help_given = 0 ;
|
||||||
args_info->version_given = 0 ;
|
args_info->version_given = 0 ;
|
||||||
args_info->extract_given = 0 ;
|
args_info->extract_given = 0 ;
|
||||||
|
args_info->long_given = 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -75,6 +77,7 @@ void init_args_info(struct gengetopt_args_info *args_info)
|
||||||
args_info->help_help = gengetopt_args_info_help[0] ;
|
args_info->help_help = gengetopt_args_info_help[0] ;
|
||||||
args_info->version_help = gengetopt_args_info_help[1] ;
|
args_info->version_help = gengetopt_args_info_help[1] ;
|
||||||
args_info->extract_help = gengetopt_args_info_help[2] ;
|
args_info->extract_help = gengetopt_args_info_help[2] ;
|
||||||
|
args_info->long_help = gengetopt_args_info_help[3] ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,6 +201,8 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
|
||||||
write_into_file(outfile, "version", 0, 0 );
|
write_into_file(outfile, "version", 0, 0 );
|
||||||
if (args_info->extract_given)
|
if (args_info->extract_given)
|
||||||
write_into_file(outfile, "extract", args_info->extract_orig, 0);
|
write_into_file(outfile, "extract", args_info->extract_orig, 0);
|
||||||
|
if (args_info->long_given)
|
||||||
|
write_into_file(outfile, "long", 0, 0 );
|
||||||
|
|
||||||
|
|
||||||
i = EXIT_SUCCESS;
|
i = EXIT_SUCCESS;
|
||||||
|
@ -1054,6 +1059,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
|
||||||
{ "help", 0, NULL, 'h' },
|
{ "help", 0, NULL, 'h' },
|
||||||
{ "version", 0, NULL, 'V' },
|
{ "version", 0, NULL, 'V' },
|
||||||
{ "extract", 1, NULL, 'x' },
|
{ "extract", 1, NULL, 'x' },
|
||||||
|
{ "long", 0, NULL, 'l' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1062,7 +1068,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
|
||||||
custom_opterr = opterr;
|
custom_opterr = opterr;
|
||||||
custom_optopt = optopt;
|
custom_optopt = optopt;
|
||||||
|
|
||||||
c = custom_getopt_long (argc, argv, "hVx:", long_options, &option_index);
|
c = custom_getopt_long (argc, argv, "hVx:l", long_options, &option_index);
|
||||||
|
|
||||||
optarg = custom_optarg;
|
optarg = custom_optarg;
|
||||||
optind = custom_optind;
|
optind = custom_optind;
|
||||||
|
@ -1095,6 +1101,18 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
|
||||||
goto failure;
|
goto failure;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case 'l': /* Include extra information in archive listing. */
|
||||||
|
|
||||||
|
|
||||||
|
if (update_arg( 0 ,
|
||||||
|
0 , &(args_info->long_given),
|
||||||
|
&(local_args_info.long_given), optarg, 0, 0, ARG_NO,
|
||||||
|
check_ambiguity, override, 0, 0,
|
||||||
|
"long", 'l',
|
||||||
|
additional_error))
|
||||||
|
goto failure;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case 0: /* Long option with no short option */
|
case 0: /* Long option with no short option */
|
||||||
case '?': /* Invalid option. */
|
case '?': /* Invalid option. */
|
||||||
|
|
|
@ -37,10 +37,12 @@ struct gengetopt_args_info
|
||||||
char * extract_arg; /**< @brief Extract file from archive. */
|
char * extract_arg; /**< @brief Extract file from archive. */
|
||||||
char * extract_orig; /**< @brief Extract file from archive original value given at command line. */
|
char * extract_orig; /**< @brief Extract file from archive original value given at command line. */
|
||||||
const char *extract_help; /**< @brief Extract file from archive help description. */
|
const char *extract_help; /**< @brief Extract file from archive help description. */
|
||||||
|
const char *long_help; /**< @brief Include extra information in archive listing help description. */
|
||||||
|
|
||||||
unsigned int help_given ; /**< @brief Whether help was given. */
|
unsigned int help_given ; /**< @brief Whether help was given. */
|
||||||
unsigned int version_given ; /**< @brief Whether version was given. */
|
unsigned int version_given ; /**< @brief Whether version was given. */
|
||||||
unsigned int extract_given ; /**< @brief Whether extract was given. */
|
unsigned int extract_given ; /**< @brief Whether extract was given. */
|
||||||
|
unsigned int long_given ; /**< @brief Whether long was given. */
|
||||||
|
|
||||||
char **inputs ; /**< @brief unamed options (options without names) */
|
char **inputs ; /**< @brief unamed options (options without names) */
|
||||||
unsigned inputs_num ; /**< @brief unamed options number */
|
unsigned inputs_num ; /**< @brief unamed options number */
|
||||||
|
|
Loading…
Reference in a new issue