hash ^= hsh_hash_string (identity->name);
return hash;
}
+
+
+
+#ifdef WINDOWS32
+
+/* Apparently windoze users like to see output dumped into their home directory,
+ not the current directory (!) */
+const char *
+default_output_path (void)
+{
+ static const char *home_dir = NULL;
+
+ /* Windows NT defines HOMEDRIVE and HOMEPATH. But give preference
+ to HOME, because the user can change HOME. */
+ if (home_dir == NULL)
+ {
+ const char *home_drive = getenv ("HOMEDRIVE");
+ const char *home_path = getenv ("HOMEPATH");
+
+ if (home_drive != NULL && home_path != NULL)
+ home_dir = xasprintf ("%s%s%c",
+ home_drive, home_path, DIRECTORY_SEPARATOR);
+ else
+ home_dir = "c:/users/default/"; /* poor default */
+ }
+ return home_dir;
+}
+
+#else
+
+/* ... whereas the rest of the world just likes it to be
+ put "here" for easy access. */
+const char *
+default_output_path (void)
+{
+ static char current_dir[] = "";
+
+ return current_dir;
+}
+
+#endif
+
const struct file_identity *);
unsigned int fn_hash_identity (const struct file_identity *);
+const char * default_output_path (void);
+
#endif /* file-name.h */
#include <stdio.h>
#include <stdlib.h>
+#include <data/file-name.h>
#include <libpspp/str.h>
#include "fwriteerror.h"
if (journal_file == NULL)
{
if (journal_file_name == NULL)
- journal_file_name = xstrdup ("pspp.jnl");
+ {
+ const char *output_path = default_output_path ();
+ journal_file_name = xasprintf ("%s%s", output_path, "pspp.jnl");
+ }
journal_file = fopen (journal_file_name, "w");
if (journal_file == NULL)
{
#include <config.h>
#include <gtk/gtk.h>
+#include <data/file-name.h>
#include "window-manager.h"
#include "output-viewer.h"
#include "helper.h"
the_output_viewer = NULL;
- unlink (OUTPUT_FILE_NAME);
+ unlink (output_file_name ());
return FALSE;
}
struct stat buf;
/* If there is no output, then don't do anything */
- if (0 != stat (OUTPUT_FILE_NAME, &buf))
+ if (0 != stat (output_file_name (), &buf))
return ;
if ( NULL == the_output_viewer )
{
if ( ov->fp == NULL)
{
- ov->fp = fopen (OUTPUT_FILE_NAME, "r");
+ ov->fp = fopen (output_file_name (), "r");
if ( ov->fp == NULL)
{
- g_print ("Cannot open %s\n", OUTPUT_FILE_NAME);
+ g_print ("Cannot open %s\n", output_file_name ());
return;
}
}
}
+#define OUTPUT_FILE_NAME "psppire.txt"
+const char *
+output_file_name (void)
+{
+ const char *dir = default_output_path ();
+ static char *filename = NULL;
+
+ if ( NULL == filename )
+ filename = xasprintf ("%s%s", dir, OUTPUT_FILE_NAME);
+
+
+ return filename;
+}
void reload_the_viewer (void);
-#define OUTPUT_FILE_NAME "psppire.txt"
-
+const char * output_file_name (void);
#endif
create_icon_factory ();
- outp_configure_driver_line (
- ss_cstr ("gui:ascii:screen:squeeze=on headers=off top-margin=0 "
- "bottom-margin=0 paginate=off length=auto width=auto "
- "emphasis=none "
- "output-file=\"" OUTPUT_FILE_NAME "\" append=yes"));
+ {
+ const char *filename = output_file_name ();
+
+ struct string config_string;
+
+ ds_init_empty (&config_string);
+
+ ds_put_format (&config_string,
+ "gui:ascii:screen:squeeze=on headers=off top-margin=0 "
+ "bottom-margin=0 paginate=off length=auto width=auto "
+ "emphasis=none "
+ "output-file=\"%s\" append=yes", filename);
- unlink (OUTPUT_FILE_NAME);
+ outp_configure_driver_line (ds_ss (&config_string));
+
+ unlink (filename);
+
+ ds_destroy (&config_string);
+ }
journal_enable ();
textdomain (PACKAGE);