}
/* Internal function: create a fileref using the given parameters. */
-static frefid_t
+frefid_t
fileref_new(gchar *filename, glui32 rock, glui32 usage, glui32 orig_filemode)
{
g_return_val_if_fail(filename != NULL, NULL);
* <note><title>Chimara</title>
* <para>
* Chimara uses a <link
- * linkend="gtk-GtkFileChooserDialog">GtkFileChooserDialog</link>.
+ * linkend="gtk-GtkFileChooserDialog">GtkFileChooserDialog</link>. The default
+ * starting location for the dialog may be set with glkunix_set_base_file().
* </para></note>
*
* @fmode must be one of these values:
return NULL;
}
+ if(glk_data->current_dir)
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser), glk_data->current_dir);
+
if(gtk_dialog_run( GTK_DIALOG(chooser) ) != GTK_RESPONSE_ACCEPT)
{
gtk_widget_destroy(chooser);
* </para></note>
* <note><title>Chimara</title>
* <para>
- * In Chimara, the file is created in the current working directory.
+ * In Chimara, the file is created in the directory last set by
+ * glkunix_set_base_file(), and otherwise in the current working directory.
* </para></note>
*
* Since filenames are highly platform-specific, you should use
{
g_return_val_if_fail(name != NULL && strlen(name) > 0, NULL);
+ /* Do any string-munging here to remove illegal Latin-1 characters from
+ filename. On ext3, the only illegal characters are '/' and '\0'. */
+
+ char *ptr = name;
+ while(*ptr++)
+ if(*ptr == '/')
+ *ptr = '_';
+
/* Find out what encoding filenames are in */
const gchar **charsets; /* Do not free */
g_get_filename_charsets(&charsets);
WARNING_S("Error during latin1->filename conversion", error->message);
return NULL;
}
-
- /* Do any string-munging here to remove illegal characters from filename.
- On ext3, the only illegal characters are '/' and '\0'. TODO: Should this
- function be allowed to reference files in other directories, or should we
- disallow '/'? */
-
- frefid_t f = fileref_new(osname, rock, usage, filemode_ReadWrite);
+
+ gchar *path;
+ if(glk_data->current_dir)
+ path = g_build_filename(glk_data->current_dir, osname, NULL);
+ else
+ path = g_strdup(osname);
g_free(osname);
+
+ frefid_t f = fileref_new(path, rock, usage, filemode_ReadWrite);
+ g_free(path);
return f;
}