Stores data in XDG_DATA_HOME instead of $HOME

This is for Flatpak compatibility
This commit is contained in:
Fries 2022-04-20 02:56:53 -07:00
parent d83641e1be
commit a7f06bb8ca
9 changed files with 23 additions and 22 deletions

View File

@ -455,14 +455,14 @@ int retVal;
retVal = MCCIServerInitialize(portNumber); retVal = MCCIServerInitialize(portNumber);
if (retVal) { if (retVal) {
/* Write port number to .mosaiccciport */ /* Write port number to .mosaiccciport */
char *home = getenv ("HOME"), *fnam; char *home = getenv ("XDG_DATA_HOME"), *fnam;
FILE *fp; FILE *fp;
if (!home) if (!home)
home = "/tmp"; home = "/tmp";
fnam = (char *)malloc (strlen (home) + 32); fnam = (char *)malloc (strlen (home) + 32);
sprintf (fnam, "%s/.mosaic/cciport", home); // SAM sprintf (fnam, "%s/cciport", home); // SAM
fp = fopen (fnam, "w"); fp = fopen (fnam, "w");
if (fp) { if (fp) {

View File

@ -506,7 +506,7 @@ mo_status mo_wipe_global_history (mo_window *win)
static char *cached_global_hist_fname = NULL; static char *cached_global_hist_fname = NULL;
mo_status mo_setup_global_history (void) mo_status mo_setup_global_history (void)
{ {
char *home = getenv ("HOME"); char *home = getenv ("XDG_DATA_HOME");
char *default_filename = get_pref_string(eGLOBAL_HISTORY_FILE); char *default_filename = get_pref_string(eGLOBAL_HISTORY_FILE);
char *filename; char *filename;
FILE *fp; FILE *fp;
@ -530,7 +530,7 @@ mo_status mo_setup_global_history (void)
printf(" the resource 'Mosaic*urlExpired').\n\n"); printf(" the resource 'Mosaic*urlExpired').\n\n");
printf("Your current history file will still exist and will not\n"); printf("Your current history file will still exist and will not\n");
printf(" be modified. However, it will no longer be updated.\n"); printf(" be modified. However, it will no longer be updated.\n");
printf(" Instead, the file '.mosaic/x-history' will be used.\n\n"); printf(" Instead, the file 'x-history' will be used.\n\n");
free(filename); free(filename);
filename = (char *)malloc((strlen (home) + strlen (default_filename) + 8) * sizeof (char)); filename = (char *)malloc((strlen (home) + strlen (default_filename) + 8) * sizeof (char));

View File

@ -214,8 +214,8 @@ PopupItem *popup_build_user_defs()
return NULL; return NULL;
} }
file = malloc(sizeof(char) * (strlen(str)+strlen("/.mosaic/user-defs")+1)); // SAM file = malloc(sizeof(char) * (strlen(str)+strlen("/user-defs")+1)); // SAM
sprintf(file, "%s/.mosaic/user-defs", str); // SAM sprintf(file, "%s/user-defs", str); // SAM
free(str); free(str);

View File

@ -3991,7 +3991,7 @@ static int mo_error_handler (Display *dsp, XErrorEvent *event)
* remarks: * remarks:
* *
****************************************************************************/ ****************************************************************************/
#define IMAGESELECT_FILENAME ".mosaic/imageselect-sites" // SAM #define IMAGESELECT_FILENAME "imageselect-sites" // SAM
void setup_imagekill(void) { void setup_imagekill(void) {
@ -4516,7 +4516,7 @@ splash_goto:
if (get_pref_string(ePERSONAL_EXTENSION_MAP)) if (get_pref_string(ePERSONAL_EXTENSION_MAP))
{ {
char *home = getenv ("HOME"); char *home = getenv ("XDG_DATA_HOME");
if (!home) if (!home)
home = "/tmp"; home = "/tmp";
@ -4535,7 +4535,7 @@ splash_goto:
global_type_map = get_pref_string(eGLOBAL_TYPE_MAP); global_type_map = get_pref_string(eGLOBAL_TYPE_MAP);
if (get_pref_string(ePERSONAL_TYPE_MAP)) if (get_pref_string(ePERSONAL_TYPE_MAP))
{ {
char *home = getenv ("HOME"); char *home = getenv ("XDG_DATA_HOME");
if (!home) if (!home)
home = "/tmp"; home = "/tmp";
@ -4673,14 +4673,14 @@ splash_goto:
/* Write pid into "~/.mosaicpid". */ /* Write pid into "~/.mosaicpid". */
{ {
char *home = getenv ("HOME"), *fnam; char *home = getenv ("XDG_DATA_HOME"), *fnam;
FILE *fp; FILE *fp;
if (!home) if (!home)
home = "/tmp"; home = "/tmp";
fnam = (char *)malloc (strlen (home) + 32); fnam = (char *)malloc (strlen (home) + 32);
sprintf (fnam, "%s/.mosaic/mosaicpid", home); // SAM sprintf (fnam, "%s/mosaicpid", home); // SAM
fp = fopen (fnam, "w"); fp = fopen (fnam, "w");
if (fp) if (fp)

View File

@ -1180,7 +1180,7 @@ static mo_root_hotlist *mo_read_hotlist (char *filename, char *home)
list = mo_new_root_hotlist(hotname, NULL); list = mo_new_root_hotlist(hotname, NULL);
list->name = mo_read_new_hotlist((mo_hotlist *)list, fp); list->name = mo_read_new_hotlist((mo_hotlist *)list, fp);
if (isnew==1) { if (isnew==1) {
fprintf(stderr,"Your hotlist has been updated to a new format!\n It is now called '.mosaic/hot.html'.\n"); fprintf(stderr,"Your hotlist has been updated to a new format!\n It is now called 'hot.html'.\n");
} }
goto done; goto done;
} }
@ -1295,7 +1295,7 @@ mo_status mo_dump_hotlist (mo_hotlist *list)
*/ */
mo_status mo_setup_default_hotlist (void) mo_status mo_setup_default_hotlist (void)
{ {
char *home = getenv ("HOME"); char *home = getenv ("XDG_DATA_HOME");
char *default_filename = get_pref_string(eDEFAULT_HOTLIST_FILE); char *default_filename = get_pref_string(eDEFAULT_HOTLIST_FILE);
char *hot_filename = get_pref_string(eDEFAULT_HOT_FILE); char *hot_filename = get_pref_string(eDEFAULT_HOT_FILE);
char *filename; char *filename;
@ -1321,6 +1321,7 @@ mo_status mo_setup_default_hotlist (void)
filename = (char *)malloc filename = (char *)malloc
((strlen (home) + strlen (hot_filename) + 8) * sizeof (char)); ((strlen (home) + strlen (hot_filename) + 8) * sizeof (char));
sprintf (filename, "%s/%s", home, hot_filename); sprintf (filename, "%s/%s", home, hot_filename);
fprintf(stderr, "%s\n", filename);
default_hotlist = mo_new_root_hotlist (filename, "Default"); default_hotlist = mo_new_root_hotlist (filename, "Default");
} }

View File

@ -1291,7 +1291,7 @@ char *homedir,*ptr;
fprintf(stderr,"home: Could not get your home directory.\n"); fprintf(stderr,"home: Could not get your home directory.\n");
return; return;
} }
sprintf(fname,"%s/.mosaic/spoof-agents",homedir); // SAM sprintf(fname,"%s/spoof-agents",homedir); // SAM
free(homedir); free(homedir);
if (!(fp=fopen(fname,"r"))) { if (!(fp=fopen(fname,"r"))) {

View File

@ -77,7 +77,7 @@ extern int srcTrace;
/* /*
This file contains support for personal annotations (pans). This file contains support for personal annotations (pans).
We have a directory called ~/.mosaic/personal-annotations (by default). We have a directory called ~/personal-annotations (by default).
In this directory is a file called LOG. In this directory is a file called LOG.
The LOG file consists of the following: The LOG file consists of the following:
@ -450,7 +450,7 @@ mo_status mo_setup_pan_list (void)
mo_init_pan (); mo_init_pan ();
home = getenv ("HOME"); home = getenv ("XDG_DATA_HOME");
/* This shouldn't happen. */ /* This shouldn't happen. */
if (!home) if (!home)

View File

@ -71,7 +71,7 @@
#define PREFS_FILE_IO 0 #define PREFS_FILE_IO 0
#define PREFERENCES_FILENAME ".mosaic/preferences" // SAM #define PREFERENCES_FILENAME "preferences" // SAM
#define PREFERENCES_MAJOR_VERSION 1 #define PREFERENCES_MAJOR_VERSION 1
#define PREFERENCES_MINOR_VERSION 0 #define PREFERENCES_MINOR_VERSION 0

View File

@ -131,16 +131,16 @@ static XtResource resources[] = {
#endif /* not _AIX */ #endif /* not _AIX */
{ "globalHistoryFile", "GlobalHistoryFile", XtRString, { "globalHistoryFile", "GlobalHistoryFile", XtRString,
sizeof (char *), sizeof (char *),
offset (global_history_file), XtRString, ".mosaic/global-history" }, // SAM offset (global_history_file), XtRString, "global-history" }, // SAM
{ "historyFile", "HistoryFile", XtRString, { "historyFile", "HistoryFile", XtRString,
sizeof (char *), sizeof (char *),
offset (history_file), XtRString, ".mosaic/x-history" }, // SAM offset (history_file), XtRString, "x-history" }, // SAM
{ "defaultHotlistFile", "DefaultHotlistFile", XtRString, { "defaultHotlistFile", "DefaultHotlistFile", XtRString,
sizeof (char *), sizeof (char *),
offset (default_hotlist_file), XtRString, ".mosaic/hotlist-default" }, // SAM offset (default_hotlist_file), XtRString, "hotlist-default" }, // SAM
{ "defaultHotFile", "DefaultHotFile", XtRString, { "defaultHotFile", "DefaultHotFile", XtRString,
sizeof (char *), sizeof (char *),
offset (default_hot_file), XtRString, ".mosaic/hot.html" }, // SAM offset (default_hot_file), XtRString, "hot.html" }, // SAM
{ "addHotlistAddsRBM", "AddHotlistAddsRBM", XtRBoolean, sizeof (Boolean), { "addHotlistAddsRBM", "AddHotlistAddsRBM", XtRBoolean, sizeof (Boolean),
offset (addHotlistAddsRBM), XtRString, "True" }, offset (addHotlistAddsRBM), XtRString, "True" },
{ "addRBMAddsRBM", "AddRBMAddsRBM", XtRBoolean, sizeof (Boolean), { "addRBMAddsRBM", "AddRBMAddsRBM", XtRBoolean, sizeof (Boolean),
@ -148,7 +148,7 @@ static XtResource resources[] = {
{ "personalAnnotationDirectory", "PersonalAnnotationDirectory", XtRString, { "personalAnnotationDirectory", "PersonalAnnotationDirectory", XtRString,
sizeof (char *), sizeof (char *),
offset (private_annotation_directory), XtRString, offset (private_annotation_directory), XtRString,
".mosaic/personal-annotations" }, // SAM "personal-annotations" }, // SAM
/* Whether selections should be fancy, by default. */ /* Whether selections should be fancy, by default. */
{ "fancySelections", "FancySelections", XtRBoolean, { "fancySelections", "FancySelections", XtRBoolean,
sizeof (Boolean), offset (default_fancy_selections), sizeof (Boolean), offset (default_fancy_selections),