aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wsutil/filesystem.c16
-rw-r--r--wsutil/filesystem.h6
2 files changed, 21 insertions, 1 deletions
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index 5f8f4db48c..1eca4cedd1 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -517,6 +517,20 @@ get_executable_path(void)
}
#endif /* _WIN32 */
+static void trim_progfile_dir(void)
+{
+ char *progfile_last_dir = find_last_pathname_separator(progfile_dir);
+
+ if (! (progfile_last_dir && strncmp(progfile_last_dir + 1, "extcap", sizeof("extcap")) == 0)) {
+ return;
+ }
+
+ *progfile_last_dir = '\0';
+ char *extcap_progfile_dir = progfile_dir;
+ progfile_dir = g_strdup(extcap_progfile_dir);
+ g_free(extcap_progfile_dir);
+}
+
/*
* Get the pathname of the directory from which the executable came,
* and save it for future use. Returns NULL on success, and a
@@ -558,6 +572,7 @@ configuration_init(
*/
progfile_dir = g_path_get_dirname(prog_pathname);
if (progfile_dir != NULL) {
+ trim_progfile_dir();
return NULL; /* we succeeded */
} else {
/*
@@ -812,6 +827,7 @@ configuration_init(
* OK, we have the path we want.
*/
progfile_dir = prog_pathname;
+ trim_progfile_dir();
return NULL;
} else {
/*
diff --git a/wsutil/filesystem.h b/wsutil/filesystem.h
index ae082e7fb7..90dd49140f 100644
--- a/wsutil/filesystem.h
+++ b/wsutil/filesystem.h
@@ -53,7 +53,11 @@ WS_DLL_PUBLIC const char *get_configuration_namespace(void);
WS_DLL_PUBLIC bool is_packet_configuration_namespace(void);
/*
- * Get the directory in which the program resides.
+ * Get the directory in which the main (Wireshark, TShark, Logray, etc)
+ * program resides.
+ * Extcaps should use get_extcap_dir() to get their path.
+ *
+ * @return The main program file directory.
*/
WS_DLL_PUBLIC const char *get_progfile_dir(void);