Commit 36e55720 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Store home directory and username at init time in the Unix library.

parent 59ff149a
...@@ -123,9 +123,11 @@ static const char *dll_dir; ...@@ -123,9 +123,11 @@ static const char *dll_dir;
static const char **dll_paths; static const char **dll_paths;
static SIZE_T dll_path_maxlen; static SIZE_T dll_path_maxlen;
const char *home_dir = NULL;
const char *data_dir = NULL; const char *data_dir = NULL;
const char *build_dir = NULL; const char *build_dir = NULL;
const char *config_dir = NULL; const char *config_dir = NULL;
const char *user_name = NULL;
HMODULE ntdll_module = NULL; HMODULE ntdll_module = NULL;
struct file_id struct file_id
...@@ -285,6 +287,29 @@ static void set_dll_path(void) ...@@ -285,6 +287,29 @@ static void set_dll_path(void)
} }
static void set_home_dir(void)
{
const char *home = getenv( "HOME" );
const char *name = getenv( "USER" );
const char *p;
if (!home || !name)
{
struct passwd *pwd = getpwuid( getuid() );
if (pwd)
{
if (!home) home = pwd->pw_dir;
if (!name) name = pwd->pw_name;
}
if (!name) name = "wine";
}
if ((p = strrchr( name, '/' ))) name = p + 1;
if ((p = strrchr( name, '\\' ))) name = p + 1;
home_dir = strdup( home );
user_name = strdup( name );
}
static void set_config_dir(void) static void set_config_dir(void)
{ {
char *p, *dir; char *p, *dir;
...@@ -299,15 +324,9 @@ static void set_config_dir(void) ...@@ -299,15 +324,9 @@ static void set_config_dir(void)
} }
else else
{ {
const char *home = getenv( "HOME" ); if (!home_dir) fatal_error( "could not determine your home directory\n" );
if (!home) if (home_dir[0] != '/') fatal_error( "the home directory %s is not an absolute path\n", home_dir );
{ config_dir = build_path( home_dir, ".wine" );
struct passwd *pwd = getpwuid( getuid() );
if (pwd) home = pwd->pw_dir;
}
if (!home) fatal_error( "could not determine your home directory\n" );
if (home[0] != '/') fatal_error( "your home directory %s is not an absolute path\n", home );
config_dir = build_path( home, ".wine" );
} }
} }
...@@ -334,6 +353,7 @@ static void init_paths( int argc, char *argv[], char *envp[] ) ...@@ -334,6 +353,7 @@ static void init_paths( int argc, char *argv[], char *envp[] )
} }
set_dll_path(); set_dll_path();
set_home_dir();
set_config_dir(); set_config_dir();
} }
......
...@@ -124,9 +124,11 @@ extern NTSTATUS CDECL nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_ST ...@@ -124,9 +124,11 @@ extern NTSTATUS CDECL nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_ST
extern NTSTATUS CDECL unix_to_nt_file_name( const ANSI_STRING *name, UNICODE_STRING *nt ) DECLSPEC_HIDDEN; extern NTSTATUS CDECL unix_to_nt_file_name( const ANSI_STRING *name, UNICODE_STRING *nt ) DECLSPEC_HIDDEN;
extern void CDECL set_show_dot_files( BOOL enable ) DECLSPEC_HIDDEN; extern void CDECL set_show_dot_files( BOOL enable ) DECLSPEC_HIDDEN;
extern const char *home_dir DECLSPEC_HIDDEN;
extern const char *data_dir DECLSPEC_HIDDEN; extern const char *data_dir DECLSPEC_HIDDEN;
extern const char *build_dir DECLSPEC_HIDDEN; extern const char *build_dir DECLSPEC_HIDDEN;
extern const char *config_dir DECLSPEC_HIDDEN; extern const char *config_dir DECLSPEC_HIDDEN;
extern const char *user_name DECLSPEC_HIDDEN;
extern HMODULE ntdll_module DECLSPEC_HIDDEN; extern HMODULE ntdll_module DECLSPEC_HIDDEN;
extern USHORT *uctable DECLSPEC_HIDDEN; extern USHORT *uctable DECLSPEC_HIDDEN;
extern USHORT *lctable DECLSPEC_HIDDEN; extern USHORT *lctable DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment