mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-04-18 08:30:45 +02:00
_dbus_get_install_root assumes that dbus-daemon is in a bin/ subdirectory. That's not a common directory structure on windows, so weaken the assumption: $somepath/bin/dbus-daemon.exe -> $somepath $somepath/dbus-daemon.exe, where somepath doesn't end in /bin/: -> $somepath i.e., use dbus-daemon.exe's directory as root if that directory is not a "bin" directory (cherry picked from commit 2d2055b2fa7f92c144e9a182a9a091ebe5215d7d)
This commit is contained in:
parent
be3d150691
commit
01d2b26bed
1 changed files with 24 additions and 17 deletions
|
|
@ -3242,26 +3242,33 @@ _dbus_get_is_errno_eagain_or_ewouldblock (void)
|
|||
* @returns #FALSE on failure
|
||||
*/
|
||||
dbus_bool_t
|
||||
_dbus_get_install_root(char *s, int len)
|
||||
_dbus_get_install_root(char *prefix, int len)
|
||||
{
|
||||
char *p = NULL;
|
||||
int ret = GetModuleFileName(NULL,s,len);
|
||||
if ( ret == 0
|
||||
|| ret == len && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
*s = '\0';
|
||||
return FALSE;
|
||||
//To find the prefix, we cut the filename and also \bin\ if present
|
||||
char* p = 0;
|
||||
int i;
|
||||
DWORD pathLength;
|
||||
int lastSlash;
|
||||
SetLastError( 0 );
|
||||
pathLength = GetModuleFileName(NULL, prefix, len);
|
||||
if ( pathLength == 0 || GetLastError() != 0 ) {
|
||||
*prefix = '\0';
|
||||
return FALSE;
|
||||
}
|
||||
else if ((p = strstr(s,"\\bin\\")))
|
||||
{
|
||||
*(p+1)= '\0';
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*s = '\0';
|
||||
return FALSE;
|
||||
lastSlash = -1;
|
||||
for (i = 0; i < pathLength; ++i)
|
||||
if (prefix[i] == '\\')
|
||||
lastSlash = i;
|
||||
if (lastSlash == -1) {
|
||||
*prefix = '\0';
|
||||
return FALSE;
|
||||
}
|
||||
//cut off binary name
|
||||
prefix[lastSlash+1] = 0;
|
||||
//cut possible "\\bin"
|
||||
if (lastSlash > 3 && strncmp(prefix + lastSlash - 4, "\\bin", 4) == 0)
|
||||
prefix[lastSlash-3] = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue