1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-27 01:25:34 +00:00

Win32: Put .elinks in Application Data if %HOME% is undefined.

This commit is contained in:
Kalle Olavi Niemitalo 2007-07-18 00:27:08 +03:00 committed by Kalle Olavi Niemitalo
parent 375d8cc905
commit f0bc5c5abe
4 changed files with 36 additions and 2 deletions

View File

@ -111,8 +111,14 @@ get_home(void)
{
unsigned char *home_elinks;
unsigned char *envhome = getenv("HOME");
unsigned char *home = envhome ? stracpy(envhome)
: elinks_dirname(program.path);
unsigned char *home = NULL;
if (!home && envhome)
home = stracpy(envhome);
if (!home)
home = user_appdata_directory();
if (!home)
home = elinks_dirname(program.path);
if (home)
strip_trailing_dir_sep(home);

View File

@ -75,4 +75,8 @@ unsigned char *get_shell(void);
* available at all. Face it, we are just cool. */
void elinks_cfmakeraw(struct termios *t);
#ifndef user_appdata_directory
#define user_appdata_directory() NULL
#endif
#endif

View File

@ -4,7 +4,11 @@
#include "config.h"
#endif
/* Get SHGFP_TYPE_CURRENT from <shlobj.h>. */
#define _WIN32_IE 0x500
#include <windows.h>
#include <shlobj.h>
#include "osdep/system.h"
@ -258,3 +262,21 @@ gettext__parse(void *arg)
return 0;
}
#endif
unsigned char *
user_appdata_directory(void)
{
#if _WIN32_WINNT >= 0x0500
HWND hwnd = GetConsoleWindow();
#else
HWND hwnd = NULL;
#endif
char path[MAX_PATH];
HRESULT hr;
hr = SHGetFolderPath(hwnd, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path);
if (hr == S_OK) /* Don't even allow S_FALSE. */
return stracpy(path);
else
return NULL;
}

View File

@ -13,6 +13,8 @@ struct terminal;
void open_in_new_win32(struct terminal *term, unsigned char *exe_name,
unsigned char *param);
unsigned char *user_appdata_directory(void);
#define user_appdata_directory user_appdata_directory
/* Stub functions: */