extcap: Use extcap.cfg as extcap config file name

"extcap" by itself can be the name of a directory that stores
extcap programs, especially if the default profile is being
used. Add an extension to the default file name so it doesn't clash.

Follow up to 4fb2ef8af8
This commit is contained in:
John Thacker 2024-02-22 20:37:20 -05:00 committed by AndersBroman
parent 0eb0d6fdb4
commit a65cce3c70
3 changed files with 6 additions and 4 deletions

View File

@ -266,7 +266,7 @@ read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fc
/** Given a module name, read the preferences associated with only that module.
* Checks for a file in the personal configuration directory named after the
* module first.
* module with a ".cfg" extension added first.
*
* @param name The preference module name, e.g. "extcap".
*/

View File

@ -4638,7 +4638,9 @@ prefs_read_module(const char *module)
}
/* Construct the pathname of the user's preferences file for the module. */
pf_path = get_persconffile_path(module, TRUE);
char *pf_name = wmem_strdup_printf(NULL, "%s.cfg", module);
pf_path = get_persconffile_path(pf_name, TRUE);
wmem_free(NULL, pf_name);
/* Read the user's module preferences file, if it exists and is not a dir. */
if (!test_for_regular_file(pf_path) || ((pf = ws_fopen(pf_path, "r")) == NULL)) {
@ -7212,7 +7214,7 @@ write_prefs(char **pf_path_return)
module_t *extcap_module = prefs_find_module("extcap");
if (extcap_module && !prefs.capture_no_extcap) {
char *ext_path = get_persconffile_path("extcap", TRUE);
char *ext_path = get_persconffile_path("extcap.cfg", TRUE);
FILE *extf;
if ((extf = ws_fopen(ext_path, "w")) == NULL) {
if (errno != EISDIR) {

View File

@ -745,7 +745,7 @@ void extcap_register_preferences(void)
* it is copied if we copy the profile even if we're not going to
* read it because extcaps are disabled.
*/
profile_register_persconffile("extcap");
profile_register_persconffile("extcap.cfg");
if (prefs.capture_no_extcap)
return;