Some more platform unification
This commit is contained in:
parent
5c9283fc68
commit
d0b5d53f92
@ -310,40 +310,32 @@ get_reg_str (const char *sub, const char *name, char *out, DWORD len)
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
char *
|
||||
get_xdir (void)
|
||||
{
|
||||
if (!xdir)
|
||||
{
|
||||
char out[256];
|
||||
#ifdef WIN32
|
||||
char out[256];
|
||||
|
||||
if (portable_mode () || !get_reg_str ("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "AppData", out, sizeof (out)))
|
||||
{
|
||||
xdir = g_strdup (".\\config");
|
||||
}
|
||||
else
|
||||
{
|
||||
xdir = g_strdup_printf ("%s\\" "HexChat", out);
|
||||
}
|
||||
if (portable_mode () || !get_reg_str ("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "AppData", out, sizeof (out)))
|
||||
{
|
||||
xdir = g_strdup (".\\config");
|
||||
}
|
||||
else
|
||||
{
|
||||
xdir = g_strdup_printf ("%s\\" "HexChat", out);
|
||||
}
|
||||
#else
|
||||
xdir = g_strdup_printf ("%s/.config/" HEXCHAT_DIR, g_get_home_dir ());
|
||||
#endif
|
||||
}
|
||||
|
||||
return xdir;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
char *
|
||||
get_xdir (void)
|
||||
{
|
||||
if (!xdir)
|
||||
xdir = g_strdup_printf ("%s/.config/" HEXCHAT_DIR, g_get_home_dir ());
|
||||
|
||||
return xdir;
|
||||
}
|
||||
|
||||
#endif /* !WIN32 */
|
||||
|
||||
static void
|
||||
check_prefs_dir (void)
|
||||
{
|
||||
|
@ -132,7 +132,7 @@ static const GOptionEntry gopt_entries[] =
|
||||
{"no-auto", 'a', 0, G_OPTION_ARG_NONE, &arg_dont_autoconnect, N_("Don't auto connect to servers"), NULL},
|
||||
{"cfgdir", 'd', 0, G_OPTION_ARG_STRING, &arg_cfgdir, N_("Use a different config directory"), "PATH"},
|
||||
{"no-plugins", 'n', 0, G_OPTION_ARG_NONE, &arg_skip_plugins, N_("Don't auto load any plugins"), NULL},
|
||||
{"plugindir", 'p', 0, G_OPTION_ARG_NONE, &arg_show_autoload, N_("Show plugin auto-load directory"), NULL},
|
||||
{"plugindir", 'p', 0, G_OPTION_ARG_NONE, &arg_show_autoload, N_("Show plugin/script auto-load directory"), NULL},
|
||||
{"configdir", 'u', 0, G_OPTION_ARG_NONE, &arg_show_config, N_("Show user config directory"), NULL},
|
||||
{"url", 0, 0, G_OPTION_ARG_STRING, &arg_url, N_("Open an irc://server:port/channel URL"), "URL"},
|
||||
#ifndef WIN32 /* uses DBUS */
|
||||
@ -223,53 +223,31 @@ fe_args (int argc, char *argv[])
|
||||
|
||||
if (arg_show_version)
|
||||
{
|
||||
#ifdef WIN32
|
||||
buffer = g_strdup_printf (DISPLAY_NAME " " PACKAGE_VERSION "\n");
|
||||
gtk_init (&argc, &argv);
|
||||
create_msg_dialog ("Version Information", buffer);
|
||||
g_free (buffer);
|
||||
#else
|
||||
printf (PACKAGE_TARNAME" "PACKAGE_VERSION"\n");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_show_autoload)
|
||||
{
|
||||
#ifdef WIN32
|
||||
/* see the chdir() below */
|
||||
char *sl, *exe = strdup (argv[0]);
|
||||
sl = strrchr (exe, '\\');
|
||||
if (sl)
|
||||
{
|
||||
*sl = 0;
|
||||
buffer = g_strdup_printf ("%s\\plugins\n", exe);
|
||||
gtk_init (&argc, &argv);
|
||||
create_msg_dialog ("Plugin Auto-load Directory", buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = g_strdup(".\\plugins\n");
|
||||
gtk_init (&argc, &argv);
|
||||
create_msg_dialog ("Plugin Auto-load Directory", buffer);
|
||||
}
|
||||
buffer = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "addons\n", get_xdir ());
|
||||
gtk_init (&argc, &argv);
|
||||
create_msg_dialog ("Plugin/Script Auto-load Directory", buffer);
|
||||
g_free (buffer);
|
||||
#else
|
||||
printf ("%s\n", HEXCHATLIBDIR"/plugins");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_show_config)
|
||||
{
|
||||
#ifdef WIN32
|
||||
buffer = g_strdup_printf ("%s\n", get_xdir ());
|
||||
buffer = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "\n", get_xdir ());
|
||||
gtk_init (&argc, &argv);
|
||||
create_msg_dialog ("User Config Directory", buffer);
|
||||
g_free (buffer);
|
||||
#else
|
||||
printf ("%s\n", get_xdir ());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -282,7 +260,7 @@ fe_args (int argc, char *argv[])
|
||||
char *tmp = strdup (argv[0]);
|
||||
char *sl;
|
||||
|
||||
sl = strrchr (tmp, '\\');
|
||||
sl = strrchr (tmp, G_DIR_SEPARATOR);
|
||||
if (sl)
|
||||
{
|
||||
*sl = 0;
|
||||
@ -292,18 +270,6 @@ fe_args (int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
if (arg_cfgdir)
|
||||
{
|
||||
if (xdir)
|
||||
g_free (xdir);
|
||||
xdir = strdup (arg_cfgdir);
|
||||
if (xdir[strlen (xdir) - 1] == '/')
|
||||
{
|
||||
xdir[strlen (xdir) - 1] = 0;
|
||||
}
|
||||
g_free (arg_cfgdir);
|
||||
}
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
#ifdef USE_XLIB
|
||||
|
@ -457,7 +457,7 @@ static const GOptionEntry gopt_entries[] =
|
||||
{"no-auto", 'a', 0, G_OPTION_ARG_NONE, &arg_dont_autoconnect, N_("Don't auto connect to servers"), NULL},
|
||||
{"cfgdir", 'd', 0, G_OPTION_ARG_STRING, &arg_cfgdir, N_("Use a different config directory"), "PATH"},
|
||||
{"no-plugins", 'n', 0, G_OPTION_ARG_NONE, &arg_skip_plugins, N_("Don't auto load any plugins"), NULL},
|
||||
{"plugindir", 'p', 0, G_OPTION_ARG_NONE, &arg_show_autoload, N_("Show plugin auto-load directory"), NULL},
|
||||
{"plugindir", 'p', 0, G_OPTION_ARG_NONE, &arg_show_autoload, N_("Show plugin/script auto-load directory"), NULL},
|
||||
{"configdir", 'u', 0, G_OPTION_ARG_NONE, &arg_show_config, N_("Show user config directory"), NULL},
|
||||
{"url", 0, 0, G_OPTION_ARG_STRING, &arg_url, N_("Open an irc://server:port/channel URL"), "URL"},
|
||||
{"version", 'v', 0, G_OPTION_ARG_NONE, &arg_show_version, N_("Show version information"), NULL},
|
||||
|
Loading…
Reference in New Issue
Block a user