diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2019-09-27 23:03:13 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2019-10-09 13:24:58 +0000 |
commit | f1285fcf061669702ca1accd7b2c50ebc8198993 (patch) | |
tree | e4e0e83535f5de15388d4af4e80841b28ef99a89 /wsutil | |
parent | 931a80492da92fe29fab6ac41eb219a6ca6b53d7 (diff) |
CMake: Don't install HTML manuals twice
HTML docs are installed to both $docdir and $pkgdatadir. Fix that
to install to $docdir only.
Change-Id: I115158585b6df9170d9a01249adbc8548df91f14
Reviewed-on: https://code.wireshark.org/review/34640
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/CMakeLists.txt | 1 | ||||
-rw-r--r-- | wsutil/filesystem.c | 33 | ||||
-rw-r--r-- | wsutil/filesystem.h | 13 |
3 files changed, 41 insertions, 6 deletions
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index c7d017cf7b..af6084268d 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -10,6 +10,7 @@ add_definitions(-DPLUGIN_DIR=\"${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_LIBDIR}\") add_definitions(-DEXTCAP_DIR=\"${CMAKE_INSTALL_PREFIX}/${EXTCAP_INSTALL_LIBDIR}\") add_definitions(-DDATA_DIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}\") +add_definitions(-DDOC_DIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DOCDIR}\") set(WSUTIL_PUBLIC_HEADERS adler32.h diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index 3526ac1fbb..97ec8a7ef7 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -57,6 +57,7 @@ char *persconffile_dir = NULL; char *datafile_dir = NULL; char *persdatafile_dir = NULL; char *persconfprofile = NULL; +char *docfile_dir = NULL; static gboolean do_store_persconffiles = FALSE; static GHashTable *profile_files = NULL; @@ -1883,6 +1884,32 @@ get_datafile_path(const char *filename) } } +static void init_docfile_dir(void) +{ + if (running_in_build_directory_flag) { + docfile_dir = g_build_filename(get_progfile_dir(), "doc", NULL); + return; + } +#ifdef _WIN32 + docfile_dir = g_strdup(get_progfile_dir()); +#else +#ifdef __APPLE__ + if (appbundle_dir != NULL) { + docfile_dir = g_build_filename(appbundle_dir, "Contents/Resources/share/doc/wireshark", (gchar *)NULL); + return; + } +#endif + docfile_dir = g_strdup(DOC_DIR); +#endif +} + +const char *get_docfile_dir(void) +{ + if (!docfile_dir) + init_docfile_dir(); + return docfile_dir; +} + /* * Return an error message for UNIX-style errno indications on open or * create operations. @@ -2261,7 +2288,7 @@ done: } gchar * -data_file_url(const gchar *filename) +help_file_url(const gchar *filename) { gchar *file_path; gchar *uri; @@ -2270,7 +2297,7 @@ data_file_url(const gchar *filename) if(g_path_is_absolute(filename)) { file_path = g_strdup(filename); } else { - file_path = g_strdup_printf("%s/%s", get_datafile_dir(), filename); + file_path = g_build_filename(get_docfile_dir(), filename, NULL); } /* XXX - check, if the file is really existing, otherwise display a simple_dialog about the problem */ @@ -2306,6 +2333,8 @@ free_progdirs(void) #endif g_free(extcap_dir); extcap_dir = NULL; + g_free(docfile_dir); + docfile_dir = NULL; } /* diff --git a/wsutil/filesystem.h b/wsutil/filesystem.h index b204fe5932..e34a3616e6 100644 --- a/wsutil/filesystem.h +++ b/wsutil/filesystem.h @@ -66,6 +66,11 @@ WS_DLL_PUBLIC const char *get_plugins_pers_dir_with_version(void); WS_DLL_PUBLIC const char *get_extcap_dir(void); /* + * Get the directory in which document files are stored. + */ +WS_DLL_PUBLIC const char *get_docfile_dir(void); + +/* * Get the flag indicating whether we're running from a build * directory. */ @@ -321,15 +326,15 @@ WS_DLL_PUBLIC gboolean copy_file_binary_mode(const char *from_filename, /* - * Given a filename return a filesystem URL. Relative paths are prefixed with - * the datafile directory path. + * Given a help filename return a filesystem URL. Relative paths are prefixed with + * the directory path. * * @param filename A file name or path. Relative paths will be prefixed with - * the data file directory path. + * the directory path. * @return A filesystem URL for the file or NULL on failure. A non-NULL return * value must be freed with g_free(). */ -WS_DLL_PUBLIC gchar* data_file_url(const gchar *filename); +WS_DLL_PUBLIC gchar* help_file_url(const gchar *filename); /* * Free the internal structtures |