Skip to content

Commit

Permalink
#1171 on 2nd thought, for windows, also get rid of dot; use g_rename;…
Browse files Browse the repository at this point in the history
… dont neglect to free old name.
  • Loading branch information
karlkleinpaste committed Aug 18, 2024
1 parent 87f16eb commit 3ae4d28
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@
/******************************************************************************
* defines
*/
#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 @@ -116,26 +112,30 @@ int settings_init(int argc, char **argv, int new_configs,

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

g_build_filename(settings.homedir,
#ifndef WIN32
".config",
#endif
XI_DIR, NULL);

/* --------------------------------------------------------------- */
/* for Linux, convert from old presence in ~, move into ~/.config. */
/* convert old presence in ~, move into ~/.config (linux), no dot. */

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) {
if (g_rename(old_gSwordDir, settings.gSwordDir) == 0) {
g_free(old_gSwordDir);
} else {
g_free(settings.gSwordDir);
settings.gSwordDir = old_gSwordDir;
}
}
else
g_free(old_gSwordDir);
/* --------------------------------------------------------------- */
#endif

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

0 comments on commit 3ae4d28

Please sign in to comment.