summaryrefslogtreecommitdiffstats
path: root/src/prefix.cpp
diff options
context:
space:
mode:
authorEduard Braun <Eduard.Braun2@gmx.de>2017-06-15 16:12:00 +0000
committerEduard Braun <Eduard.Braun2@gmx.de>2017-06-15 17:14:58 +0000
commit1a66c0aae0da7c3b860d06e72f5ff87f444bc462 (patch)
tree10481b9018fbee27ddce4f033f1be64c628b75b3 /src/prefix.cpp
parentRemove cmake checks for unused libraries. (diff)
downloadinkscape-1a66c0aae0da7c3b860d06e72f5ff87f444bc462.tar.gz
inkscape-1a66c0aae0da7c3b860d06e72f5ff87f444bc462.zip
Improve Windows relocation support.
Remove a lot of unused / overly compicated path manipulation functions and replace them with a solution that also handles the case where inkscape.exe is located in a /bin subdirectory.
Diffstat (limited to 'src/prefix.cpp')
-rw-r--r--src/prefix.cpp66
1 files changed, 10 insertions, 56 deletions
diff --git a/src/prefix.cpp b/src/prefix.cpp
index 4e2204cff..cf0f752d2 100644
--- a/src/prefix.cpp
+++ b/src/prefix.cpp
@@ -419,72 +419,26 @@ br_extract_prefix (const char *path)
#ifdef __WIN32__
-
/**
* Provide a similar mechanism for Win32. Enable a macro,
* WIN32_DATADIR, that can look up subpaths for inkscape resources
- */
-
-#include <windows.h>
-#include <glibmm/ustring.h>
-
-/**
- * Return the directory of the .exe that is currently running
*/
-Glib::ustring win32_getExePath()
-{
- gunichar2 path[2048];
- GetModuleFileNameW(0, (WCHAR*) path, 2048);
- gchar *exe = g_utf16_to_utf8(path, -1, 0,0,0);
- gchar *dir = g_path_get_dirname(exe);
- Glib::ustring ret = dir;
- g_free(dir);
- g_free(exe);
- return ret;
-}
-
/**
- * Return the relocatable version of the datadir,
- * probably c:\inkscape
+ * 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
*/
-static Glib::ustring win32_getDataDir()
+char *win32_append_module_path(const char *relative_path)
{
- Glib::ustring dir = win32_getExePath();
- if (INKSCAPE_DATADIR && *INKSCAPE_DATADIR &&
- strcmp(INKSCAPE_DATADIR, ".") != 0)
- {
- dir += "\\";
- dir += INKSCAPE_DATADIR;
- }
- return dir;
-}
-
-static Glib::ustring win32_getResourcePath(const Glib::ustring &childPath)
-{
- Glib::ustring dir = win32_getDataDir();
- if (childPath.size() > 0)
- {
- dir += "\\";
- dir += childPath;
- }
- return dir;
-}
+ 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);
-/**
- * This is the visible utility function
- */
-char *win32_relative_path(const char *childPath)
-{
- static char *returnPath = 0;
- if (!childPath)
- childPath = "";
- Glib::ustring resourcePath = win32_getResourcePath(childPath);
- if (returnPath)
- free(returnPath);
- returnPath = strdup(resourcePath.c_str());
- return returnPath;
+ return return_path;
}
#endif /* __WIN32__ */