diff options
| author | Eduard Braun <Eduard.Braun2@gmx.de> | 2017-06-15 19:45:48 +0000 |
|---|---|---|
| committer | Eduard Braun <Eduard.Braun2@gmx.de> | 2017-06-15 19:45:48 +0000 |
| commit | 2cf0d896e314d46767ec2c0f7e2734473f523490 (patch) | |
| tree | e0b2c020d99d1ac292db1b3a01de5c5783c57a47 /src/prefix.cpp | |
| parent | cleanup (diff) | |
| download | inkscape-2cf0d896e314d46767ec2c0f7e2734473f523490.tar.gz inkscape-2cf0d896e314d46767ec2c0f7e2734473f523490.zip | |
Refactor 1a66c0aae0da7c3b860d06e72f5ff87f444bc462 and allow to use a different data directory by setting the environment variable INKSCAPE_DATADIR at runtime
Diffstat (limited to 'src/prefix.cpp')
| -rw-r--r-- | src/prefix.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/prefix.cpp b/src/prefix.cpp index cf0f752d2..c8bf7abec 100644 --- a/src/prefix.cpp +++ b/src/prefix.cpp @@ -425,20 +425,31 @@ br_extract_prefix (const char *path) */ /** - * Gets the directory where folders like "lib" and "share" are located and appends a relative path - * Handles the case where inkscape.exe is located in a "bin" subfolder as well + * Get the Windows-equivalent of INKSCAPE_DATADIR and append a relative path + * + * - by default INKSCAPE_DATADIR will be relative to the called executable + * (typically inkscape/share but also handles the case where the executable is in a /bin subfolder) + * - to override set the INKSCAPE_DATADIR environment variable */ -char *win32_append_module_path(const char *relative_path) +char *win32_append_datadir(const char *relative_path) { + static gchar *datadir; + if (!datadir) { + gchar const *inkscape_datadir = g_getenv("INKSCAPE_DATADIR"); + if (inkscape_datadir) { + datadir = g_strdup(inkscape_datadir); + } else { + gchar *module_path = g_win32_get_package_installation_directory_of_module(NULL); + datadir = g_build_filename(module_path, "share", NULL); + g_free(module_path); + } + } + if (!relative_path) { relative_path = ""; } - gchar *module_path = g_win32_get_package_installation_directory_of_module(NULL); - gchar *return_path = g_build_filename(module_path, relative_path, NULL); - g_free(module_path); - - return return_path; + return g_build_filename(datadir, relative_path, NULL); } #endif /* __WIN32__ */ |
