mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
libwine: Use the argv[0] directory as bin directory only if all other methods fail.
This commit is contained in:
parent
b618910b84
commit
16c8ca8082
@ -152,16 +152,16 @@ static char *get_runtime_libdir(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* return the directory that contains the main exe at run-time */
|
/* return the directory that contains the main exe at run-time */
|
||||||
static char *get_runtime_bindir( const char *argv0 )
|
static char *get_runtime_exedir(void)
|
||||||
{
|
{
|
||||||
char *p, *bindir, *cwd;
|
|
||||||
int len, size;
|
|
||||||
|
|
||||||
#ifdef EXE_LINK
|
#ifdef EXE_LINK
|
||||||
|
char *p, *bindir;
|
||||||
|
int size;
|
||||||
|
|
||||||
for (size = 256; ; size *= 2)
|
for (size = 256; ; size *= 2)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
if (!(bindir = malloc( size ))) break;
|
if (!(bindir = malloc( size ))) return NULL;
|
||||||
if ((ret = readlink( EXE_LINK, bindir, size )) == -1) break;
|
if ((ret = readlink( EXE_LINK, bindir, size )) == -1) break;
|
||||||
if (ret != size)
|
if (ret != size)
|
||||||
{
|
{
|
||||||
@ -175,6 +175,14 @@ static char *get_runtime_bindir( const char *argv0 )
|
|||||||
}
|
}
|
||||||
free( bindir );
|
free( bindir );
|
||||||
#endif
|
#endif
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* return the base directory from argv0 */
|
||||||
|
static char *get_runtime_argvdir( const char *argv0 )
|
||||||
|
{
|
||||||
|
char *p, *bindir, *cwd;
|
||||||
|
int len, size;
|
||||||
|
|
||||||
if (!(p = strrchr( argv0, '/' ))) return NULL;
|
if (!(p = strrchr( argv0, '/' ))) return NULL;
|
||||||
|
|
||||||
@ -370,21 +378,32 @@ void wine_init_argv0_path( const char *argv0 )
|
|||||||
if (!(basename = strrchr( argv0, '/' ))) basename = argv0;
|
if (!(basename = strrchr( argv0, '/' ))) basename = argv0;
|
||||||
else basename++;
|
else basename++;
|
||||||
|
|
||||||
bindir = get_runtime_bindir( argv0 );
|
bindir = get_runtime_exedir();
|
||||||
libdir = get_runtime_libdir();
|
|
||||||
|
|
||||||
if (bindir && !is_valid_bindir( bindir ))
|
if (bindir && !is_valid_bindir( bindir ))
|
||||||
{
|
{
|
||||||
build_dir = running_from_build_dir( bindir );
|
build_dir = running_from_build_dir( bindir );
|
||||||
free( bindir );
|
free( bindir );
|
||||||
bindir = NULL;
|
bindir = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
libdir = get_runtime_libdir();
|
||||||
if (libdir && !bindir && !build_dir)
|
if (libdir && !bindir && !build_dir)
|
||||||
{
|
{
|
||||||
build_dir = running_from_build_dir( libdir );
|
build_dir = running_from_build_dir( libdir );
|
||||||
if (!build_dir) bindir = build_path( libdir, LIB_TO_BINDIR );
|
if (!build_dir) bindir = build_path( libdir, LIB_TO_BINDIR );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!libdir && !bindir && !build_dir)
|
||||||
|
{
|
||||||
|
bindir = get_runtime_argvdir( argv0 );
|
||||||
|
if (bindir && !is_valid_bindir( bindir ))
|
||||||
|
{
|
||||||
|
build_dir = running_from_build_dir( bindir );
|
||||||
|
free( bindir );
|
||||||
|
bindir = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (build_dir)
|
if (build_dir)
|
||||||
{
|
{
|
||||||
argv0_name = build_path( "loader/", basename );
|
argv0_name = build_path( "loader/", basename );
|
||||||
|
Loading…
Reference in New Issue
Block a user