- /* Read in the next lot of text */
- while (fgets (line, OUTPUT_LINE_WIDTH, ov->fp) != NULL)
- {
- chars_inserted = TRUE;
- gtk_text_buffer_insert (ov->buffer, &end_iter, line, -1);
- }
+#ifdef __CYGWIN__
+ /*
+ Apparently Windoze is not capabale of writing to a file whilst
+ another (or the same) process is reading from it. Therefore, we
+ must close the file after reading it, and clear the entire buffer
+ before writing to it.
+ This will be slower for large buffers, but should work
+ (in so far as anything ever works on windows).
+ */
+ {
+ GtkTextIter start_iter;
+ FILE *fp = fopen (output_file_name (), "r");
+ if ( !fp)
+ {
+ g_warning ("Cannot open %s\n", output_file_name ());
+ return;
+ }
+
+ /* Delete all the entire buffer */
+ gtk_text_buffer_get_start_iter (ov->buffer, &start_iter);
+ gtk_text_buffer_delete (ov->buffer, &start_iter, &end_iter);
+
+
+ gtk_text_buffer_get_start_iter (ov->buffer, &start_iter);
+ /* Read in the next lot of text */
+ while (fgets (line, viewer_width + 1, fp) != NULL)
+ {
+ chars_inserted = TRUE;
+ gtk_text_buffer_insert (ov->buffer, &start_iter, line, -1);
+ }
+
+ fclose (fp);
+ }
+#else
+ {
+ if ( ov->fp == NULL)
+ {
+ ov->fp = fopen (output_file_name (), "r");
+ if ( ov->fp == NULL)
+ {
+ g_warning ("Cannot open %s\n", output_file_name ());
+ return;
+ }
+ }
+
+ /* Read in the next lot of text */
+ while (fgets (line, viewer_width + 1, ov->fp) != NULL)
+ {
+ chars_inserted = TRUE;
+ gtk_text_buffer_insert (ov->buffer, &end_iter, line, -1);
+ }
+ }
+#endif