diff options
author | João Valverde <j@v6e.pt> | 2023-01-20 10:14:38 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2023-01-20 10:16:20 +0000 |
commit | 597bcca9ee7c4e00da52bc3363b97381c9a516fc (patch) | |
tree | 1dd6db9c352ccfd032214a2c34ac3b34c8e0a846 | |
parent | d45a733258dea5297c59fce63f09a48aeb480bdf (diff) |
wsutil: Add get_docfile_path()
-rw-r--r-- | wsutil/filesystem.c | 22 | ||||
-rw-r--r-- | wsutil/filesystem.h | 9 |
2 files changed, 31 insertions, 0 deletions
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index 460501bec3..f1fb58805f 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -2130,6 +2130,28 @@ get_datafile_path(const char *filename) } /* + * Construct the path name of a global documentation file, given the + * file name. + * + * The returned file name was g_malloc()'d so it must be g_free()d when the + * caller is done with it. + */ +char * +get_docfile_path(const char *filename) +{ + if (running_in_build_directory_flag) { + /* We're running in the build directory and the requested file is a + * generated (or a test) file. Return the file name in the build + * directory (not in the source/data directory). + * (Oh the things we do to keep the source directory pristine...) + */ + return g_build_filename(get_progfile_dir(), filename, (char *)NULL); + } else { + return g_build_filename(get_doc_dir(), filename, (char *)NULL); + } +} + +/* * Return an error message for UNIX-style errno indications on open or * create operations. */ diff --git a/wsutil/filesystem.h b/wsutil/filesystem.h index 627b7f55bb..19c9db81f7 100644 --- a/wsutil/filesystem.h +++ b/wsutil/filesystem.h @@ -136,6 +136,15 @@ WS_DLL_PUBLIC const char *get_doc_dir(void); * The returned file name was g_malloc()'d so it must be g_free()d when the * caller is done with it. */ +WS_DLL_PUBLIC char *get_docfile_path(const char *filename); + +/* + * Construct the path URL of a global documentation file, given the + * file name. + * + * The returned file name was g_malloc()'d so it must be g_free()d when the + * caller is done with it. + */ WS_DLL_PUBLIC char *doc_file_url(const char *filename); /* |