[gz_open] Use compress and write consistent with calling functions.

This commit is contained in:
John Ralls 2021-09-12 13:29:10 -07:00
parent 8e4c4948cc
commit d7eae0664f

View File

@ -95,7 +95,7 @@ typedef struct
gint fd;
gchar* filename;
gchar* perms;
gboolean compress;
gboolean write;
} gz_thread_params_t;
/* Callback structure */
@ -125,8 +125,8 @@ gnc_v2_book_version_string; /* see gnc-book-xml-v2 */
/* Forward declarations */
static FILE* try_gz_open (const char* filename, const char* perms,
gboolean use_gzip,
gboolean compress);
gboolean compress,
gboolean write);
static gboolean is_gzipped_file (const gchar* name);
static gboolean wait_for_gzip (FILE* file);
@ -1433,7 +1433,7 @@ gz_thread_func (gz_thread_params_t* params)
goto cleanup_gz_thread_func;
}
if (params->compress)
if (params->write)
{
while (success)
{
@ -1514,13 +1514,13 @@ cleanup_gz_thread_func:
}
static FILE*
try_gz_open (const char* filename, const char* perms, gboolean use_gzip,
gboolean compress)
try_gz_open (const char* filename, const char* perms, gboolean compress,
gboolean write)
{
if (strstr (filename, ".gz.") != NULL) /* its got a temp extension */
use_gzip = TRUE;
compress = TRUE;
if (!use_gzip)
if (!compress)
return g_fopen (filename, perms);
{
@ -1554,10 +1554,10 @@ try_gz_open (const char* filename, const char* perms, gboolean use_gzip,
}
params = g_new (gz_thread_params_t, 1);
params->fd = filedes[compress ? 0 : 1];
params->fd = filedes[write ? 0 : 1];
params->filename = g_strdup (filename);
params->perms = g_strdup (perms);
params->compress = compress;
params->write = write;
thread = g_thread_new ("xml_thread", (GThreadFunc) gz_thread_func,
params);
@ -1573,7 +1573,7 @@ try_gz_open (const char* filename, const char* perms, gboolean use_gzip,
return g_fopen (filename, perms);
}
if (compress)
if (write)
file = fdopen (filedes[1], "w");
else
file = fdopen (filedes[0], "r");