[beast/win32] Relocate paths relative to the installed executable (under windows).
- From: Stefan Westerfeld <stw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [beast/win32] Relocate paths relative to the installed executable (under windows).
- Date: Mon, 28 Sep 2009 12:11:37 +0000 (UTC)
commit 6822ec0265453f97d1d1260ff7632b51d71f3104
Author: Stefan Westerfeld <stefan space twc de>
Date: Mon Sep 28 12:10:20 2009 +0200
Relocate paths relative to the installed executable (under windows).
Based on 016_relocate_via_exename.diff.
bse/bsewin32.cc | 32 +++++++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/bse/bsewin32.cc b/bse/bsewin32.cc
index 688fdb9..6258a25 100644
--- a/bse/bsewin32.cc
+++ b/bse/bsewin32.cc
@@ -74,6 +74,32 @@ bse_win32_waiter_wait (BseWin32Waiter *waiter,
return 1;
}
+static void
+transform_bslash_to_slash (char *buffer)
+{
+ while (*buffer)
+ {
+ if (*buffer == '\\')
+ *buffer = '/';
+ buffer++;
+ }
+}
+
+static void
+cut_last_name_component (char *buffer, int times)
+{
+ while (times--)
+ {
+ char *delim = buffer;
+ for (char *i = buffer; *i; i++)
+ {
+ if (*i == '/')
+ delim = i;
+ }
+ *delim = 0;
+ }
+}
+
extern "C" const char*
bse_path_relocate (const char *path)
{
@@ -81,7 +107,11 @@ bse_path_relocate (const char *path)
const int prefix_len = strlen ("/c/beast");
if (strncmp (path, "/c/beast", prefix_len) == 0)
{
- char *relocated = g_strdup_printf ("c:/beast%s", path + prefix_len);
+ char buffer[512];
+ GetModuleFileName(NULL, buffer, sizeof(buffer));
+ transform_bslash_to_slash (buffer);
+ cut_last_name_component (buffer, 2);
+ char *relocated = g_strdup_printf ("%s%s", buffer, path + prefix_len);
result = g_intern_string (relocated);
g_free (relocated);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]