Skip to content

Commit

Permalink
fix #1171 move ~/.xiphos to ~/.config/xiphos for standards compatibil…
Browse files Browse the repository at this point in the history
…ity.
  • Loading branch information
karlkleinpaste committed Aug 16, 2024
1 parent e6f9d07 commit cdbf233
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/main/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@
/******************************************************************************
* defines
*/
#define XI_DIR ".xiphos"
#ifndef WIN32
#define XI_DIR "xiphos" /* modern choice, within ~/.config */
#define OLD_XI_DIR ".xiphos" /* for compatibility movement */
#else
#define XI_DIR ".xiphos" /* kept the same for Windows users */
#endif

/******************************************************************************
* globals
Expand Down Expand Up @@ -95,6 +100,7 @@ int settings_init(int argc, char **argv, int new_configs,
char *env;
struct stat buf;
gboolean buf_says_empty = FALSE;
char *old_gSwordDir;

settings.first_run = FALSE;
/* set program title */
Expand All @@ -110,7 +116,26 @@ int settings_init(int argc, char **argv, int new_configs,

/* set gSwordDir to $home + .xiphos */
settings.gSwordDir =
g_build_filename(settings.homedir, XI_DIR, NULL);
g_build_filename(settings.homedir, ".config", XI_DIR, NULL);

#ifndef WIN32
/* --------------------------------------------------------------- */
/* for Linux, convert from old presence in ~, move into ~/.config. */

old_gSwordDir = g_build_filename(settings.homedir, OLD_XI_DIR, NULL);

if ((g_access(old_gSwordDir, F_OK) == 0) &&
(g_access(settings.gSwordDir, F_OK) != 0)) {
/* ~/.xiphos exists, but not ~/.config/xiphos: move. */
if (rename(old_gSwordDir, settings.gSwordDir) == 0) {
g_free(old_gSwordDir);
} else {
g_free(settings.gSwordDir);
settings.gSwordDir = old_gSwordDir;
}
}
/* --------------------------------------------------------------- */
#endif

/* if gSwordDir does not exist, create it. */
if (g_access(settings.gSwordDir, F_OK) == -1) {
Expand Down

0 comments on commit cdbf233

Please sign in to comment.